嗨,我想用这种格式放置 json 嵌套对象:
[{"lat":-6.92015,"lon":107.67024,"value":0.1},{"lat":-6.88283,"lon":107.60149,"value":0.1},..]
进入这个 json 数组:
{"max": 30, "data": [...]}
并将导致这种格式:
{"max": 30, "data": [{"lat":-6.92015,"lon":107.67024,"value":0.1},...]}
我当前的代码:
$data[] = array(lat=>(float)$row["geo_lat"], lon=>(float)$row["geo_long"], value=>1);
$post_data = json_encode(array('max' => 30, 'data' => $data));
echo $post_data;
我怎么能这样做?谢谢