array_key_first() and array_key_last()

The array_key_first() and array_key_last() functions were introduced in PHP 7.3 for retrieving the first and last key of an array, respectively:

$array = ['a' => 1, 'b' => 2, 'c' => 3];

var_dump(array_key_first($array));
var_dump(array_key_last($array));

Executing the code shown above will print the output shown below:

string(1) "a"
string(1) "c"