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