array_key_last返回数组的最后一个键
/**
* Gets the last key of an array
*
* Get the last key of the given array without affecting the internal array pointer.
*
* @link https://secure.php.net/array_key_last
* @param array $array An array
* @return string|int|null Returns the last key of array if the array is not empty; NULL otherwise.
* @since 7.3
*/
function array_key_last(array $array) { }
示例:
$array = [
'a' => 'cat',
'b' => 'dog',
'c' => 'pig'
];
$result = array_key_last($array);
var_dump($result);
//结果
//string(1) "c"