<?php
$raw_data = '{"status":"ok","data":{"rdata":[{"r1":"1","a1":"3323"},{"r1":"255","a1":"332443"} ]}}';
$json_obj = json_decode($raw_data);
$r_data = '{"r10":"1","a1":"3323"}';
$r_data_obj = json_decode($r_data);
foreach($json_obj->data->rdata as $key=>$tag_name){
if($tag_name->r1 == "1"){
//unset($json_obj->data->rdata[$key]);
}
}
$json_obj->data->rdata[] = $r_data_obj;
print_r($json_obj);
echo json_encode($json_obj);
code好读板 http://pastebin.com/4Kg7hrdJ
json 经过 unset 处理过后就会 json_encode 输出就自动变成 object
可是 print_r 还是 array