PHP key()Functions
Examples
Return the element key name from the current internal pointer position:
<?php
$people=array("Peter","Joe","Glenn","Cleveland");
echo "The key from the current position is: " . key($people);
?>
$people=array("Peter","Joe","Glenn","Cleveland");
echo "The key from the current position is: " . key($people);
?>
Run example »
Definition and Usage
The key() function returns the key name of the element at the current internal pointer position.
If an error occurs, the function returns FALSE.
Syntax
key(array)
| Parameter | Description |
|---|---|
| array | Required. Specifies the array to use. |
Technical Details
| Return value: | Returns the key name of the array element pointed to by the current internal pointer. |
|---|---|
| PHP Version: | 4+ |
Complete PHP Array Reference Other Extensions