Return the key of the element at the current internal pointer position in the array.
<?php $people=array(“Peter”,“Joe”,“Glenn”,“Cleveland”); echo “The key from the current position is: “ . key($people); ?> |
The key() function returns the key of the element at the current internal pointer position.
It returns FALSE on error.
key(array) |
Parameter |
Description |
array |
Required. Specifies the array to use. |
Return Value: |
Returns the key of the array element currently pointed to by the internal pointer. |
PHP Version: |
4+ |