我正在尝试从以下数组(last.fm)返回值[name]
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
)
)
)
)
我试过
echo $results['0'][0];
其中$ results是数组变量,但不起作用。我没有线索。你能帮助我重新调整[名字](在这种情况下是Beyonce)的价值吗?
提前致谢
答案 0 :(得分:4)
您需要通过它的密钥访问每个嵌套结果。在这种情况下"结果" > 0(数字索引)> "名称":
echo $results['results'][0]['name'];