我从web服务获取巨大的json数据并通过loop.but循环解析使我的网站变慢。是否还有其他方法来获取php中的json数据? 这是我的片段。
for ($i=0; $i < count($trid) ; $i++) {
$operator_aval=operator_routes_a($trid[$i],$Fromd);
$page1=file_get_contents($operator_aval);
$data1=json_decode($page1,true);
$opr_res=count($data1['routes']);
for ($j=0; $j < count($data1['routes']); $j++) {
$origin=$data1['routes'][$j]['route']['origin'];
$destination=$data1['routes'][$j]['route']['destination'];
$status=$data1['routes'][$j]['route']['status'];
$service_name=$data1['routes'][$j]['route']['operator_service_name'];
// echo $origin."--".$destination."<br>";
if(($Fromname==$origin) && ($Toname==$destination) &&($status!="Unavailable-Service Left" || $status!="Unavailable-Cancelled")&& $service_name!=""){
echo 'trid : '.$trid[$i].'reservation id : '.$data1['routes'][$j]['route']['reservation_id']."---".$data1['routes'][$j]['route']['travels']."<br>";
$count++;
}
}
}