The key() function returns the element key from the current internal pointer position.
PHP key() Function has the following syntax.
key(array)
Parameter | Is Required | Description |
---|---|---|
array | Required. | Array to use |
This function returns FALSE on error.
Return the element key from the current internal pointer position:
<?php
$people=array("A","B","C","D");
echo "The key from the current position is: " . key($people);
?>
The code above generates the following result.