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

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

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

        PHP foreach 循环键值

        时间:2023-09-22
      1. <small id='ICbgs'></small><noframes id='ICbgs'>

            • <bdo id='ICbgs'></bdo><ul id='ICbgs'></ul>
            • <legend id='ICbgs'><style id='ICbgs'><dir id='ICbgs'><q id='ICbgs'></q></dir></style></legend>

                  <tbody id='ICbgs'></tbody>

              1. <tfoot id='ICbgs'></tfoot>
                  <i id='ICbgs'><tr id='ICbgs'><dt id='ICbgs'><q id='ICbgs'><span id='ICbgs'><b id='ICbgs'><form id='ICbgs'><ins id='ICbgs'></ins><ul id='ICbgs'></ul><sub id='ICbgs'></sub></form><legend id='ICbgs'></legend><bdo id='ICbgs'><pre id='ICbgs'><center id='ICbgs'></center></pre></bdo></b><th id='ICbgs'></th></span></q></dt></tr></i><div id='ICbgs'><tfoot id='ICbgs'></tfoot><dl id='ICbgs'><fieldset id='ICbgs'></fieldset></dl></div>
                  本文介绍了PHP foreach 循环键值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在运行这个数据库调用来获取多维数组我正在尝试获取每个键的键,但是当我尝试时它出现空白或数组.

                  I am running this DB call to get me multi-dimensional array I am trying to get the keys of each but when I try it comes up blank or as array.

                  $root_array = array();
                  $sites = $this->sites($member_id);
                  foreach ($sites as $site){
                      $records = $this->db->select('p.name as place_name, p.id as place_id,p.active as place_status')
                                  ->from('places p')
                                  ->join('members_permissions pm','pm.sites_id = p.sites_id and pm.members_id ='.$member_id)
                                  ->where('p.active', 0)
                                  ->get();
                  
                      $places = $records->result_array();
                      $places['name'] = $site['name'];
                      foreach($places as $place){
                         $root_array[$site['name']][] = $place;
                      }
                  
                  }
                  return $root_array;
                  

                  这是我的 php 循环:

                  here is my php that loops through:

                  <?php foreach($places as $site): ?>
                      <h5><?=key($site)?></h5>
                          <?php foreach($site as $place): ?>
                              <h6><?=$place['place_name']?></h6>
                          <?php endforeach?>
                  
                  <?php endforeach ?>
                  

                  此外,当我运行一个只是吐出数组的测试时,这就是结果,我试图呈现的是[费城]

                  Also when I run a test which just spits out the array this is the result, What I am trying to render is [Philadelphia]

                  [Philadelphia] => Array
                          (
                              [0] => Array
                                  (
                                      [place_name] => XYX
                                      [place_id] => 103200
                                      [place_status] => 0
                                  )
                  
                              [1] => Array
                                  (
                                  [place_name] => YYYY
                                  [place_id] => 232323
                                  [place_status] => 0
                              )
                  

                  推荐答案

                  你可以像这样访问你的数组键:

                  You can access your array keys like so:

                  foreach ($array as $key => $value)
                  

                  这篇关于PHP foreach 循环键值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:laravel 5.x 中的 hasMany 与 BeingToMany 下一篇:在 PHP 中使用 foreach 循环时查找数组的最后一个元

                  相关文章

                  最新文章

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

                      <tfoot id='oW3P6'></tfoot>

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