Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
包含以下内容的键的php json响应$_Php_Json - Fatal编程技术网

包含以下内容的键的php json响应$

包含以下内容的键的php json响应$,php,json,Php,Json,首先,谢谢你的阅读。这是我的密码 data.json { "$descriptor": "Testing Json", "$url": "NULL", "$totalResults": 1499, "$startIndex": 1, "$itemsPerPage": 1499, "$resources": [ { "$url": "NULL", "$uuid": "5e

首先,谢谢你的阅读。这是我的密码

data.json

{
      "$descriptor": "Testing Json",
      "$url": "NULL",
      "$totalResults": 1499,
      "$startIndex": 1,
      "$itemsPerPage": 1499,
      "$resources": [
        {
          "$url": "NULL",
          "$uuid": "5e7b9312-52e5-4fe1-b3e4-633ca04c9764",
          "$httpStatus": "OK"

        }
    ]
}
index.php

    <?php

    $file_name = "data.json";

    $file = json_decode(file_get_contents($file_name));

    ?>

    <table class="table">
        <thead>
            <tr>
                <th>Product Code</th>
                <th>Product Name</th>
                <th>Available Stock</th>
            </tr>
        </thead>
        <br>
        <tbody>

        <?php 
LINE 39 ->  foreach($file->$resources as $mydata)
        {
            ?>

            <tr>
                <td><?php echo $mydata->url; ?></td>
                <td><?php echo $mydata->uuid; ?></td>
                <td><?php echo $mydata->httpStatus; ?></td>
            </tr>

            <?php
        };
        ?>

        </tbody>
    </table>
我只是想知道你是否能解释一下,我猜这是因为关键名字前面的美元符号。目前,我正在手动导入此文件,因为它将是来自api服务器的查询结果

如果是因为美元符号,我将如何消除它们

谢谢
Anthony,

问题是由
$
引起的(您需要这些吗?)

$file->{'$resources'}
或者,如果解码为关联数组:

$file = json_decode(file_get_contents($file_name), true);
$file['$resources']
但是您的
echo
语句也将访问一个数组:

echo $mydata['$url'];

非常感谢你,几个小时来你一直在逼我
echo $mydata['$url'];