Get first key in a (possibly) associative array?
2019 Update Starting from PHP 7.3, there is a new built in function called array_key_first() which will retrieve the first key from the given array without resetting the internal pointer. Check out the documentation for more info. You can use reset and key: reset($array); $first_key = key($array); It’s essentially the same as your initial code, … Read more