Php 单个值的数组输出
阵列:Php 单个值的数组输出,php,arrays,json,Php,Arrays,Json,阵列: Array ( [2010091907] => Array ( [home] => Array ( [score] => Array ( [1] => 7 [2] => 17 [3] => 1
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 />";
}
}
$json=json\u decode($data,true);
foreach($json作为$key=>$date){
回显“Key:.$Key.”值:.$date.
;
foreach($团队日期){
echo“Team:.$Team.”
;
}
}
应该是$team['abbr']
在你的内心深处
将输出
ATL
如果只想输出singl值。在您的循环结构中,JochenJung得到了以下修复。试试:
foreach($arr as$key=>$date){
回显“Key:.$Key.”值:.$date.
;
foreach($团队日期){
echo“团队:.$Team['abbr'];
}
}
ATL
foreach ($arr as $key => $date) {
echo "Key: ".$key."; Value: ".$date."<br />";
foreach ($date as $team) {
echo "Team: ".$team['abbr'];
}
}