简体   繁体   English

我如何从Php中的Json检索图像

[英]How can i Retrieve Image from Json in Php

How can i retrieve Image from JSON as the image are stored in a folder. 当图像存储在文件夹中时,如何从JSON检索图像。 The name output name is working but did not show any image. 名称输出名称正在运行,但未显示任何图像。 PHP 的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 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: 您在json中缺少逗号,它应该是:

[
    {
        "Name": "AnyName",
        "Image": "img/bk.png"
    }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM