array_key_last()
Get the last key of the given array without affecting the internal array pointer.
No Hooks.
Return
String|Int|null
. The last key of array if the array . is not empty; null otherwise.
Usage
array_key_last( $arr );
- $arr(array) (required)
- An array.
Changelog
Since 5.9.0 | Introduced. |
Code of array_key_last() array key last WP 6.0
function array_key_last( array $arr ) { if ( empty( $arr ) ) { return null; } end( $arr ); return key( $arr ); }