Forum Moderators: coopster
I have this array:
myarray = array("key1" => "val1", "key2" => "val2", and so on)
How can I get "key1" => "val1" returned to me when I don't know the value of key1 is?
Thanks
$output = array_slice($input, 0, 1);
would get you the first element of the array (key and value).
Or, if you don't mind affecting the input array
$output=array_shift [php.net]($input);
which will give you the value in the first element, but remove that from the input array.
list($key1, $val1) = each($myarray);