How can I find the value of the first element in an associative array in PHP?

riloo

New Member
I have an array like this:\[code\]$array = array( 'fruit1' => 'apple', 'fruit2' => 'orange', 'fruit3' => 'grape',);\[/code\]Is there a function that'll grab \[code\]'apple'\[/code\] (the first key) from that array? Or do I have no choice but to do this?\[code\]function firstkey($array){ for($array as $first) { return $first; }}\[/code\]
 
Back
Top