Possible duplicate:Get the first key in an [possibly] associative array?
I have this array:
Array ( ['foobar'] => Array ( [key1] => value1 [key2] => value2 ) )
I want to get the name of the first index (foobar). How can i do this?
Assuming you did not use each() , next() , prev() or in any other way, you pointed to a pointer to an array:
each()
next()
prev()
key($array);
Another way:
$keys = array_keys($array); echo $keys[0];