php - how to change json format from array to object? -
i need description how correct print format of json code:
while($row = mysqli_fetch_array($result)){ //step 4 action current row $img = $row['image']; $link = $row['link']; $posts[] = array('img'=> $img, 'url'=> $link); //echo $row['image'] . "<br/> " ; //echo $row['link'] . "<br/> " ; } echo json_encode($posts, json_pretty_print);
the output
[ { "img": "catalog\/demo\/banners\/iphone6.jpg", "url": "index.php?route=product\/product&path=57&product_id=49" }, { "img": "catalog\/demo\/banners\/macbookair.jpg", "url": "" } ]
i want:
{ "img": "catalog\/demo\/banners\/iphone6.jpg", "url": "index.php?route=product\/product&path=57&product_id=49" }, { "img": "catalog\/demo\/banners\/macbookair.jpg", "url": "" }
this not valid format of json
{ "img": "catalog\/demo\/banners\/iphone6.jpg", "url": "index.php?route=product\/product&path=57&product_id=49" }, { "img": "catalog\/demo\/banners\/macbookair.jpg", "url": "" }
you have ,
separator, separates what? have make array.
Comments
Post a Comment