我还没有完成代码,但我希望在名为“data”的数组中获取$pictures
的所有值。因此,在阵列“数据”中存在具有特定信息的阵列图片。然后将其编码为JSON。
function jSONEncode($data){
foreach ($data->data as $key){
$url = $key->images->thumbnail->url;
$longitude = $key->location->longitude;
$latitude = $key->location->longitude;
$pictures = array(
"url" => $url,
"latitude" => $longitude,
"longitude" => $latitude,
"name" => "bla bla"
);
};
}
答案 0 :(得分:1)
这可能会对您有所帮助:
$json['data'] = array();
foreach ($data->data as $key){
$url = $key->images->thumbnail->url;
$longitude = $key->location->longitude;
$latitude = $key->location->longitude;
$pictures = array(
"url" => $url,
"latitude" => $longitude,
"longitude" => $latitude,
"name" => "bla bla"
);
$json['data'][] = $pictures;
};
echo json_encode($json);
exit;
现在,您可以使用json.data
访问javascript