PHP 怎么解析远程URL 传过来json ,在前端显示出来

2024年12月04日 23:40
有3个网友回答
网友(1):

比如:
$jsonData = '{"ErrorCode":0,"Success":true,"ErrMessage":"","HasData":true,"Records":[{"Time":"2014-08-19 07:47:10","Location":"广东省河源市G25黄田至义合高速路段","Reason":"驾驶中型以上载客载货汽车、危险物品运输车辆以外的其他机动车行驶超过规定时速10%未达20%的","count":"150","status":"0","department":"河源市公安局交通警察支队高速公路二大队","Degree":"3","Code":"1352A","Archive":"4416307900262638","Telephone":null,"Excutelocation":null,"Excutedepartment":null,"Category":"","Latefine":"0","Punishmentaccording":null,"Illegalentry":null,"Locationid":4416,"LocationName":"广东河源","DataSourceID":9992,"RecordType":"实时数据","Poundage":"25","CanProcess":"1","UniqueCode":"fbbe4d88558cff1f25a8770a42cd4e3e","SecondaryUniqueCode":"1993287","DegreePoundage":"0","Other":"","CanprocessMsg":"","CooperPoundge":"25","ActivePoundge":"-1","CanUsePackage":"0"}],"ResultType":"实时数据","LastSearchTime":"","PackageName":"","RemainCount":0,"Other":""}
';
$data = json_decode($jsonData,TRUE);
var_dump($data);
这个$data 是一个数组,输出数组就简单了(foreach)

网友(2):

boolean tag = true;

网友(3):

楼主研究一下json_decode json_encode