key
Get key names from associative array
key()
function returns the key name of the current pointer to the element in the array.
If an error occurs, the function returns FALSE.
This function is similar to current() , except that the result returns are different. current()
function returns the value of the element, while the key() function returns the key name of the element.
Return the element key name from the current internal pointer position:
<?php $people = array ( "Bill" , "Steve" , "Mark" , "David" ) ; echo "The current position of the key is:" . key ( $people ) ; ?>
Try it yourself
key ( array )
parameter | describe |
---|---|
array | Required. Specifies the array to be used. |