数组:
Array
(
[2010091907] => Array
(
[home] => Array
(
[score] => Array
(
[1] => 7
[2] => 17
[3] => 10
[4] => 7
[5] => 0
[T] => 41
)
[abbr] => ATL
[to] => 2
)
我如何访问abbr并显示其值。这是我的PHP代码:
$json=json_decode($data,true);
foreach ($json as $key => $date) {
echo "Key: ".$key."; Value: ".$date."<br />";
foreach ($date as $team) {
echo "Team: ".$team."<br />";
}
}
答案 0 :(得分:1)
应为$team['abbr']
在你内在的foreach()
答案 1 :(得分:1)
echo $array[2010091907]['home']['abbr'];
会输出
ATL
如果您只想输出单个值。在你的循环结构中,Jochen Jung得到了下面的修复。
答案 2 :(得分:0)
尝试this:
foreach ($arr as $key => $date) {
echo "Key: ".$key."; Value: ".$date."<br />";
foreach ($date as $team) {
echo "Team: ".$team['abbr'];
}
}