Вот как я получаю результат, пока я пытаюсь кодировать строку в формате JSON. Я хочу, что URL должен быть в этом: http://ipaddress/Up/user_images/549279.jpg
Json string с кодировкой url или json для url
РЕЗУЛЬТАТ:
{ "результат": [{ "ID": "42", "имя": "HTTP: // IPADDRESS/Up/user_images/380289.jpg "}, {" ID ":" 43" , "имя": "HTTP: //IPADDRESS/Up/user_images/995062.jpg"}, { "ID": "44", "имя" : "http: //IPADDRESS/Up/user_images/171544.jpg"}, {"id": "41", "name": "http: //IPADDRESS/Up/user_images/549279.jpg"}]}
Внимание: json_decode() ожидает параметр 1, чтобы быть строка, массив приведен в C: \ XAMPP \ HTDOCS \ JSN \ PHP_Scripts \ getAllEmp.php на линии 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);
http://stackoverflow.com/questions/4319105/remove-trailing-slash-from-string-php см это, это поможет – Anjali