PHP key () function
Examples
Returns the element keys inside pointer from the current 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);
?>
Running instance »
Definition and Usage
key () function returns the name of the key elements of the interior from the current cursor position.
If the error, the function returns FALSE.
grammar
key( array )
参数 | 描述 |
---|---|
array | 必需。规定要使用的数组。 |
technical details
return value: | Returns the key current internal pointer points to the array element. |
---|---|
PHP version: | 4+ |
Complete PHP Array Reference