如何访问PHP中的第三维数组? [英] How to access a third dimension array in php?
本文介绍了如何访问PHP中的第三维数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图访问tLastName在此JSON文件:
I am trying to access tLastName in this json file:
{
"PlayerInfo": {
"76561198090954934": {
"uUserID": 1,
"tFirstName": "[TAG] Flooze",
"tLastName": "[TAG] Flooze",
"iInitTimestamp": 1455213482,
"iLastSeen": 1455667539,
"tInitIP": "---",
"tLastIP": "---",
"iSecondsPlayed": 66990,
"iConnections": 12,
"tReason": "Disconnected",
"bAlive": false
},
"76561198001294252": {
"uUserID": 2,
"tFirstName": "[HUN] Pepe",
"tLastName": "[HUN] Pepe",
"iInitTimestamp": 1455213482,
"iLastSeen": 1455316439,
"tInitIP": "---",
"tLastIP": "---",
"iSecondsPlayed": 28210,
"iConnections": 2,
"tReason": "Disconnected",
"bAlive": true
}
}
}
这是一个清单,许多这些,我想它正好呼应tLastName在PHP中的每个人。
it is a list with many of these and I would like it to echo just "tLastName" for each of them in php.
我已经得到了:
$file = file_get_contents('http://nbd.esy.es/json/jsondb.json');
$json = json_decode($file, true);
所以这个应该把它放到一个数组?
So this should put it into an array?
在先进的感谢!
推荐答案
试试这个:
$file = file_get_contents('http://nbd.esy.es/json/jsondb.json');
$json = json_decode($file, true);
foreach ($json['PlayerInfo'] as $playerInfo) {
$lastName = $playerInfo['tLastName'];
}
这篇关于如何访问PHP中的第三维数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文