code:
$hyperlink = str_replace("%2F","","http://localhost/android/images/");
if($num>0)
{
$products_arr=array();
$products_arr["data"]=array();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row);
$product_item=array(
"image_name" => $image_name,
"image_url" => $hyperlink.$file_s
);
array_push($products_arr["data"], $product_item);
}
echo json_encode($products_arr);
}
I have create a json file using php now I want to add hyperlink inside an array function. I am using str_replace("%2F","","http://localhost/android/images/");
but its not working and json file look like as mention below:
{
"data": [
{
"image_name": "cap-1",
"image_url": "http:\/\/localhost\/android\/images\/Cap-01.png"
},
{
"image_name": "cap-2",
"image_url": "http:\/\/localhost\/android\/images\/Cap-02.png"
},
{
"image_name": "cap-3",
"image_url": "http:\/\/localhost\/android\/images\/Cap-03.png"
},
{
"image_name": "ear-1",
"image_url": "http:\/\/localhost\/android\/images\/Ears-01.png"
},
{
"image_name": "ear-2",
"image_url": "http:\/\/localhost\/android\/images\/Ears-02.png"
},
{
"image_name": "ear-3",
"image_url": "http:\/\/localhost\/android\/images\/Ears-03.png"
},
{
"image_name": "hair-1",
"image_url": "http:\/\/localhost\/android\/images\/Hair Color-01.png"
},
{
"image_name": "hair-2",
"image_url": "http:\/\/localhost\/android\/images\/Hair Color-02.png"
}
]
}
So how can I remove "\" element from url? Please help me.
Thank You