$json = array();
$json[]["data"] = $val;
echo json_encode($json,JSON_FORCE_OBJECT);
bu çıktıyı aldım lakin yine istediğim çıktı değil.
{,…}
0:{data: {0: {id: "1", category: "real_estate", title: "aaaaaaa", location: "63 Birch Street",…},…}}
data:{0: {id: "1", category: "real_estate", title: "aaaaaaa", location: "63 Birch Street",…},…}
0:{id: "1", category: "real_estate", title: "aaaaaaa", location: "63 Birch Street",…}
1:{id: "2", category: "real_estate", title: "bbbbbbbb", location: "63 Birch Street",…}