1. <legend id='YXu9E'><style id='YXu9E'><dir id='YXu9E'><q id='YXu9E'></q></dir></style></legend>

    1. <tfoot id='YXu9E'></tfoot>

    2. <i id='YXu9E'><tr id='YXu9E'><dt id='YXu9E'><q id='YXu9E'><span id='YXu9E'><b id='YXu9E'><form id='YXu9E'><ins id='YXu9E'></ins><ul id='YXu9E'></ul><sub id='YXu9E'></sub></form><legend id='YXu9E'></legend><bdo id='YXu9E'><pre id='YXu9E'><center id='YXu9E'></center></pre></bdo></b><th id='YXu9E'></th></span></q></dt></tr></i><div id='YXu9E'><tfoot id='YXu9E'></tfoot><dl id='YXu9E'><fieldset id='YXu9E'></fieldset></dl></div>
    3. <small id='YXu9E'></small><noframes id='YXu9E'>

      • <bdo id='YXu9E'></bdo><ul id='YXu9E'></ul>
    4. 使用 PHP foreach 解析 JSON 数组

      时间:2023-09-23
    5. <tfoot id='nAzIr'></tfoot>
        <tbody id='nAzIr'></tbody>
      <i id='nAzIr'><tr id='nAzIr'><dt id='nAzIr'><q id='nAzIr'><span id='nAzIr'><b id='nAzIr'><form id='nAzIr'><ins id='nAzIr'></ins><ul id='nAzIr'></ul><sub id='nAzIr'></sub></form><legend id='nAzIr'></legend><bdo id='nAzIr'><pre id='nAzIr'><center id='nAzIr'></center></pre></bdo></b><th id='nAzIr'></th></span></q></dt></tr></i><div id='nAzIr'><tfoot id='nAzIr'></tfoot><dl id='nAzIr'><fieldset id='nAzIr'></fieldset></dl></div>

          • <bdo id='nAzIr'></bdo><ul id='nAzIr'></ul>

            <small id='nAzIr'></small><noframes id='nAzIr'>

            1. <legend id='nAzIr'><style id='nAzIr'><dir id='nAzIr'><q id='nAzIr'></q></dir></style></legend>

              • 本文介绍了使用 PHP foreach 解析 JSON 数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                想知道为什么我的 PHP 代码不会在 JSON 数据中显示值"的所有值":

                Wondering why my PHP code will not display all "Value" of "Values" in the JSON data:

                $user = json_decode(file_get_contents($analytics));
                foreach($user->data as $mydata)
                {
                     echo $mydata->name . "
                ";
                
                }        
                foreach($user->data->values as $values)
                {
                     echo $values->value . "
                ";
                }
                

                第一个 foreach 工作正常,但第二个会引发错误.

                The first foreach works fine, but the second throws an error.

                {
                   "data": [
                      {
                         "id": "MY_ID/insights/page_views_login_unique/day",
                         "name": "page_views_login_unique",
                         "period": "day",
                         "values": [
                            {
                               "value": 1,
                               "end_time": "2012-05-01T07:00:00+0000"
                            },
                            {
                               "value": 6,
                               "end_time": "2012-05-02T07:00:00+0000"
                            },
                            {
                               "value": 5,
                               "end_time": "2012-05-03T07:00:00+0000"
                            }, ...
                

                推荐答案

                您可能想要执行以下操作:

                You maybe wanted to do the following:

                foreach($user->data as $mydata)
                
                    {
                         echo $mydata->name . "
                ";
                         foreach($mydata->values as $values)
                         {
                              echo $values->value . "
                ";
                         }
                    }        
                

                这篇关于使用 PHP foreach 解析 JSON 数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:循环内 PDO 语句的绑定参数 下一篇:在 foreach 循环中什么更好...使用 &amp;符号或基

                相关文章

                最新文章

                  <small id='6TTZ5'></small><noframes id='6TTZ5'>

                  <i id='6TTZ5'><tr id='6TTZ5'><dt id='6TTZ5'><q id='6TTZ5'><span id='6TTZ5'><b id='6TTZ5'><form id='6TTZ5'><ins id='6TTZ5'></ins><ul id='6TTZ5'></ul><sub id='6TTZ5'></sub></form><legend id='6TTZ5'></legend><bdo id='6TTZ5'><pre id='6TTZ5'><center id='6TTZ5'></center></pre></bdo></b><th id='6TTZ5'></th></span></q></dt></tr></i><div id='6TTZ5'><tfoot id='6TTZ5'></tfoot><dl id='6TTZ5'><fieldset id='6TTZ5'></fieldset></dl></div>
                  • <bdo id='6TTZ5'></bdo><ul id='6TTZ5'></ul>

                  1. <legend id='6TTZ5'><style id='6TTZ5'><dir id='6TTZ5'><q id='6TTZ5'></q></dir></style></legend>
                  2. <tfoot id='6TTZ5'></tfoot>