<legend id='MDbRo'><style id='MDbRo'><dir id='MDbRo'><q id='MDbRo'></q></dir></style></legend>

      <bdo id='MDbRo'></bdo><ul id='MDbRo'></ul>

  1. <small id='MDbRo'></small><noframes id='MDbRo'>

    <tfoot id='MDbRo'></tfoot>
    <i id='MDbRo'><tr id='MDbRo'><dt id='MDbRo'><q id='MDbRo'><span id='MDbRo'><b id='MDbRo'><form id='MDbRo'><ins id='MDbRo'></ins><ul id='MDbRo'></ul><sub id='MDbRo'></sub></form><legend id='MDbRo'></legend><bdo id='MDbRo'><pre id='MDbRo'><center id='MDbRo'></center></pre></bdo></b><th id='MDbRo'></th></span></q></dt></tr></i><div id='MDbRo'><tfoot id='MDbRo'></tfoot><dl id='MDbRo'><fieldset id='MDbRo'></fieldset></dl></div>
    1. php - foreach - 通过键名获取具体数据

      时间:2023-09-21

              <tbody id='qiMsh'></tbody>

            <legend id='qiMsh'><style id='qiMsh'><dir id='qiMsh'><q id='qiMsh'></q></dir></style></legend>

            <tfoot id='qiMsh'></tfoot>
            • <bdo id='qiMsh'></bdo><ul id='qiMsh'></ul>

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

              • <i id='qiMsh'><tr id='qiMsh'><dt id='qiMsh'><q id='qiMsh'><span id='qiMsh'><b id='qiMsh'><form id='qiMsh'><ins id='qiMsh'></ins><ul id='qiMsh'></ul><sub id='qiMsh'></sub></form><legend id='qiMsh'></legend><bdo id='qiMsh'><pre id='qiMsh'><center id='qiMsh'></center></pre></bdo></b><th id='qiMsh'></th></span></q></dt></tr></i><div id='qiMsh'><tfoot id='qiMsh'></tfoot><dl id='qiMsh'><fieldset id='qiMsh'></fieldset></dl></div>
                本文介绍了php - foreach - 通过键名获取具体数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                如何从以下 foreach 代码中通过键名获取特定数据.

                how to get specific data by key name from the following foreach code.

                    <?php
                    foreach ($_SESSION as $key=>$val)
                    echo $key." ".$val."<br/>";
                    ?>
                

                数组看起来像这样想要获取特定键的值.

                array is look like this want to get value of specific key.

                   {"name":"bedroom","rent":"sale","props":"","leases":""}
                

                我尝试了以下代码但不起作用

                i have tried following code but doesn't work

                echo "checking key sep. ".$key[rent];
                

                如果可能,我可以通过姓名或租金等关键名称访问.

                if possible i can access by key name like name or rent.

                推荐答案

                格式为JSON,需要先使用json_decode()

                The format is in JSON , you need to decode it first by using json_decode()

                这样的东西...

                $yourJSON = '{"name":"bedroom","rent":"sale","props":"","leases":""}';
                $yourarray = json_decode($yourJSON,1);
                

                然后您可以像这样使用 foreach 构造来循环 $yourarray.

                You can then loop the $yourarray using the foreach construct like this.

                foreach($yourarray as $key=>$val)
                {
                echo $key." ".$val."<br/>";
                }
                

                用于从中检索特定密钥..

                For retrieving a specific key from it..

                   echo $yourarray['rent']; //"prints" sale
                

                这篇关于php - foreach - 通过键名获取具体数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在php中删除数组键名称中的空格? 下一篇:如何乘数直到达到个位数并计算数字?

                相关文章

                最新文章

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

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