0
我有一些JSON數據,我想匹配一些條件後重新安裝它。PHP繼續獲得循環中的休息價值
$mm='a';
$nn='104';
$jn=array();
$j2='[
{"a":"c","n":"103","t":"rfg"},
{"a":"a","n":"104","t":"bmf"},// <- find the data, re-install from the next line
{"a":"b","n":"105","t":"tit"},
{"a":"a","n":"106","t":"iou"},
{"a":"b","n":"107","t":"wdf"}
]';
$t2=json_decode($j2);
foreach($t2 as $d2){
if($mm==$d2->a&&$nn==$d2->n){
continue;
}
$jn['a']=$d2->a;
$jn['n']=$d2->n;
$jn['t']=$d2->t;
$p.=json_encode($jn).',';
}
echo '['.substr($p,0,-1).']';
我只需要找到比賽後返回JSON數據[{"a":"b","n":"105","t":"tit"},{"a":"a","n":"106","t":"iou"},{"a":"b","n":"107","t":"wdf"}]
什麼是yiur錯誤還是什麼? (除了錯誤的'json_encode'用法) –