data: [{id: 1, category: "real_estate", title: "Steak House Restaurant", location: "63 Birch Street",…},…]
Kodlar ->
$someArray = [];
foreach($val as $s){
array_push($someArray, [
'id' => $s['id'],
'title' => $s['title'],
'latitude' => $s['latitude'],
'longitude' => $s['longitude'],
'location' => $s['location']
]);
}
echo json_encode($someArray,JSON_FORCE_OBJECT);
Kodun çıktısı ->
{,…}
0:{id: "1", title: "aaaaaaa", latitude: "51.541599", longitude: "-0.112588", location: "63 Birch Street"}
1:{id: "2", title: "aaaaaaa", latitude: "51.541599", longitude: "-0.112588", location: "63 Birch Street"}
Yapmak istediğimiz
{,…}
data:[{id: 1, category: "real_estate", title: "Steak House Restaurant", location: "63 Birch Street",…},…]
0:{id: 1, category: "real_estate", title: "Steak House Restaurant", location: "63 Birch Street",…}
1:{id: 2, category: "bar_restaurant", title: "Blue Chilli", location: "1882 Trainer Avenue",…}
grkm16