PHP array_key_first() Function
Complete PHP Array Reference Manual
Example
Get the first key of an array:
1 , ' b ' => 2 , ' c ' => 3 ] ; $firstKey = array_key_first ( $array ) ; echo $firstKey ; ?>The output of the code above is:
a
Definition and Usage
The array_key_first() function gets the first key of the specified array.
Gets the first key of the specified array without affecting the original array's internal pointer.
Syntax
array_key_first ( array $array ) : mixed
| Parameters | Description |
|---|---|
| array | The array to operate on. |
Technical Details
| Return Value: | Returns the first key of array (if not empty), otherwise returns null. |
|---|---|
| PHP Version: | PHP 7 >= 7.3.0, PHP 8 |