The key() function is used to get the index element of the current array position.
This function returns FALSE on error.
Returns the key of the array element that is currently being pointed to by the internal pointer
Parameter | Description |
---|---|
array | Required. Specifies the array to use |
Syntax
key(array)
Example
$people=array("James","Cooper","Samuel","Alex");
echo "key: " . key($people);
Output
key: 0