I have simple problem trying to figure out.
I needs to get output to echo url address like this.
"image": "http://test.info/json/movies/1.jpg"
i'm trying stuck with this code
<?php
include_once 'db_functions.php';
$db = new DB_Functions();
$products = $db->getAllProducts();
$a = array();
$b = array();
$c = 'test.info/json/movies/';
if ($products != false){
$no_of_users = mysql_num_rows($products);
while ($row = mysql_fetch_array($products)) {
$b["image"] = $c.''.$row["photo"];
array_push($a,$b);
}
echo json_encode($a);
}
?>
Currently i'm getting json output as following.
"image":"http:\/\/test.info\/json\/movies\/uploadsimage0214.png"
please help me to get rid of extra backslashes.
You can either use str_replace(); or just just the flag JSON_UNESCAPED_SLASHES
as
echo json_encode($a, JSON_UNESCAPED_SLASHES);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.