……
……
建议学会用使用关键词搜索,搜索引擎远没有你想象中的智能。
又是个数组循环的问题
$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";
}
}