How can i retrieve Image from JSON as the image are stored in a folder. The name output name is working but did not show any image. PHP
<?php
$json_file = file_get_contents('file.json');
$array = json_decode($json_file, true);
foreach ($array as $key => $value) {
echo $value['Name'];
echo $value['Image'];
}
?>
JSON
[{
"Name": "AnyName"
"Image": "img/bk.png"
}]
尝试:
echo '<img src="' . $value['Image'] . '" height="100%" width="100%">'
You're missing a comma in your json, it should be:
[
{
"Name": "AnyName",
"Image": "img/bk.png"
}
]
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.