You need to access each nested result by it's key. In this case "results" > 0 (numeric index) > "name":
echo $results['results'][0]['name'];
Question
I'm trying to return the value [name] from the following array (last.fm)
Array
(
[totalResults] => 9771
[startIndex] => 0
[itemsPerPage] => 1
[results] => Array
(
[0] => Array
(
[name] => Beyoncé
[mbid] => 183105b5-3e68-4748-9086-2c1c11bf7a3d
[url] => http://www.last.fm/music/Beyonc%C3%A9
[streamable] => 1
[image] => Array
(
[small] =>
[large] => http://userserve-ak.last.fm/serve/34/95313353.png
)
)
)
)
I tried
echo $results['0'][0];
Where $results is the array variable, but not worked. I have no clue. Can you help me to retune the value from [name] (in this case Beyonce) ?
Thanks in advance
Solution
You need to access each nested result by it's key. In this case "results" > 0 (numeric index) > "name":
echo $results['results'][0]['name'];