This is how I'm getting result while I'm trying to encode string in JSON format. I want that url should be in this: http://ipaddress/Up/user_images/549279.jpg
RESULT:
{"result":[{"id":"42","name":"http://IPADDRESS/Up/user_images/380289.jpg"},{"id":"43","name":"http://IPADDRESS/Up/user_images/995062.jpg"},{"id":"44","name":"http://IPADDRESS/Up/user_images/171544.jpg"},{"id":"41","name":"http://IPADDRESS/Up/user_images/549279.jpg"}]}
Warning: json_decode() expects parameter 1 to be string, array given in C:\xampp\htdocs\jsn\PHP_Scripts\getAllEmp.php on line 26
//creating a blank array
$result = array();
$r1 = array();
//looping through all the records fetched
while ($row = mysqli_fetch_array($r)){
//Pushing name and id in the blank array created
array_push($result,array(
"id"=>$row['userID'],
"name"=>$ur.$row['userPic'],
));
}
//Displaying the array in json format
echo json_encode(array('result'=>$result));
$r1= json_decode($result, true);
echo ($r1);
// echo json_decode(array("result"=>$r1));
mysqli_close($con);