[英]Parent, child JSON parsing in PHP?
I have a JSON file with a structure as below: 我有一个JSON文件,结构如下:
{
"data": {
"last_all": {
"value": "1194999",
"value_int": "2342",
"display": "332",
"disp1": "953.3",
"current": "BLR"
},
"item": "NRF",
"low": "494.55"
}
}
How would I go about getting the value from "display" from last_all? 我如何从last_all获取“display”的值?
This part is where I get stuck: print $obj['last_all']['display'];
这部分是我卡住的地方:
print $obj['last_all']['display'];
you cant pass more then 3 params so I cant tell PHP to look under data then last_all then display. 你不能通过超过3个参数,所以我不能告诉PHP查看数据然后last_all然后显示。
Simple oversight. 简单的疏忽。 You're missing 'data' in your array reference:
您在数组引用中缺少“数据”:
$obj = json_decode($json_string, true);
print $obj['data']['last_all']['display'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.