You can use the key function:
key () returns the index element of the current position of the array.
And, as a quick example, you can consider this part of the code:
$array = array( 'first' => 123, 'second' => 456, 'last' => 789, ); reset($array);
It will output, as expected, the key of the second element:
string 'second' (length=6)
source share