How to get single value from this multi-dimensional PHP array
Example print_r($myarray)
Array
(
[0] => Array
(
[id] => 6578765
[name] => John Smith
[first_name] => John
[last_name] => Smith
[link] => http://www.example.com
[gender] => male
[email] => [email protected]
[timezone] => 8
[updated_time] => 2010-12-07T21:02:21+0000
)
)
Question, how to get the $myarray
in single value like:
echo $myarray['email']; will show [email protected]
Look at the keys and indentation in your print_r
:
echo $myarray[0]['email'];
echo $myarray[0]['gender'];
...etc
Use array_shift
function
$myarray = array_shift($myarray);
This will move array elements one level up and you can access any array element without using [0]
key
echo $myarray['email'];
will show [email protected]