猿问

php 读取 json 里面的字段内容

{"count":{"左脑":2,"右脑":3,"全脑":2,"全脑1":1},"score":{"左脑":8,"右脑":14,"全脑":15,"全脑1":8},"pingjun":{"左脑":4,"右脑":4.6666666666667,"全脑":7.5,"全脑1":8}} 如何读取 json里面的 pingjun这个值

不负相思意
浏览 380回答 2
2回答

杨__羊羊

示例代码如下:<?phpheader("Content-type:&nbsp;text/html;&nbsp;charset=utf-8");$postArray&nbsp;=&nbsp;'[{"count":{"左脑":2,"右脑":3,"全脑":2,"全脑1":1},"score":{"左脑":8,"右脑":14,"全脑":15,"全脑1":8},"pingjun":{"左脑":4,"右脑":4.6666666666667,"全脑":7.5,"全脑1":8}}]';$de_json&nbsp;=&nbsp;json_decode($postArray,&nbsp;true);echo&nbsp;$de_json[0]['pingjun']['左脑'];?>json 数组结构如图:

森栏

$a = '{"count":{"左脑":2,"右脑":3,"全脑":2,"全脑1":1},"score":{"左脑":8,"右脑":14,"全脑":15,"全脑1":8},"pingjun":{"左脑":4,"右脑":4.6666666666667,"全脑":7.5,"全脑1":8}}';$b = json_decode($a);$status = $b->pingjun;
随时随地看视频慕课网APP
我要回答