PHP array_key_last() Function Guide & Examples
The array_key_last() function is a new addition in PHP version 7.3.0, which is used to return the last key name in an array.
The syntax for using this function is as follows:
array_key_last(array $array): mixed
$array is the array to be operated on.
Here is an example of using the array_key_last() function:
$array = ['a' => 1, 'b' => 2, 'c' => 3];
$lastKey = array_key_last($array);
echo $lastKey; // 输出:c
In the example above, $array is an associative array, and the array_key_last() function returns the last key name “c”. Next, output this key name to the screen.