我怎样才能从Php中的Json中检索图像

时间:2017-04-07 13:26:47

标签: php json

如何将图像存储在文件夹中,从JSON检索图像。名称输出名称正在运行,但未显示任何图像。 的 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"

}]

2 个答案:

答案 0 :(得分:0)

尝试:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:text="TextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/list_item" />
</LinearLayout>

答案 1 :(得分:-1)

你在json中遗漏了一个逗号,应该是:

[
    {
        "Name": "AnyName",
        "Image": "img/bk.png"
    }
]
相关问题