How can I get the first element of an array with key-value pairs in it in PHP? If I have $people = [3 => “John”, 5 => “Jane”, 11 => “Steven”]; how can I get John out of People without knowing the key (3)?
@fpendovskiAug 12.2022 — #You can use reset() : $firstPerson = reset($people); But if modifying the array's pointers is an issue, you could also use: array_pop(array_reverse($people));