php自己实现json解析,这段json怎样用php解析?

……

……

建议学会用使用关键词搜索,搜索引擎远没有你想象中的智能。

又是个数组循环的问题

$str = '{"code":0,"data":{"base":{"studentCount":1},"students":[{"key":"444-4559603","id":42603,"xuehao":"20129","kaohao":"171828","name":"小马","class":"1718","school":"444","subjectRank":{"2211551":{"score":102,"others":{"subScore":86,"objScore":16,"orgScore":102,"fujiati":0},"class":2,"all":24,"school":24},"2211552":{"score":118,"others":{"subScore":82,"objScore":36,"orgScore":118,"fujiati":0},"class":3,"all":65,"school":65},"2211553":{"score":118,"others":{"subScore":39,"objScore":79,"orgScore":118,"fujiati":0},"class":1,"all":2,"school":2},"2211554":{"score":99.5,"others":{"subScore":63.5,"objScore":36,"orgScore":99.5,"fujiati":0},"class":1,"all":4,"school":4},"2211555":{"score":96,"others":{"subScore":46,"objScore":50,"orgScore":96,"fujiati":0},"class":1,"all":1,"school":1},"2213160":{"score":90.5,"others":{"subScore":48.5,"objScore":42,"orgScore":90.5,"fujiati":0},"class":1,"all":26,"school":26},"totalScore":{"score":624,"others":{"subScore":365,"objScore":259,"orgScore":624,"fujiati":0},"class":1,"all":1,"school":1}}}],"grades":{}}}';

$json_arr = json_decode($str,true);

$students_list = $json_arr['data']['students'];

foreach($students_list as $k=>$v){

foreach($v['subjectRank'] as $subject_code=>$r){

echo $subject_code.': 得分'.$r['score'].',班排'.$r['class'].',总'.$r['all'].',年排'.$r['school']."\n";

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值