• <bdo id='O9hkH'></bdo><ul id='O9hkH'></ul>
    <tfoot id='O9hkH'></tfoot>
  • <small id='O9hkH'></small><noframes id='O9hkH'>

        <legend id='O9hkH'><style id='O9hkH'><dir id='O9hkH'><q id='O9hkH'></q></dir></style></legend>
        <i id='O9hkH'><tr id='O9hkH'><dt id='O9hkH'><q id='O9hkH'><span id='O9hkH'><b id='O9hkH'><form id='O9hkH'><ins id='O9hkH'></ins><ul id='O9hkH'></ul><sub id='O9hkH'></sub></form><legend id='O9hkH'></legend><bdo id='O9hkH'><pre id='O9hkH'><center id='O9hkH'></center></pre></bdo></b><th id='O9hkH'></th></span></q></dt></tr></i><div id='O9hkH'><tfoot id='O9hkH'></tfoot><dl id='O9hkH'><fieldset id='O9hkH'></fieldset></dl></div>
      1. 从 Foreach Loop PHP 创建关联数组

        时间:2023-09-21
      2. <small id='SCsgh'></small><noframes id='SCsgh'>

        <tfoot id='SCsgh'></tfoot>

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

            <tbody id='SCsgh'></tbody>

                  <bdo id='SCsgh'></bdo><ul id='SCsgh'></ul>
                  本文介绍了从 Foreach Loop PHP 创建关联数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有这个 foreach 循环:

                  I have this foreach loop:

                  foreach($aMbs as $aMemb){
                      $ignoreArray = array(1,3);
                      if (!in_array($aMemb['ID'],$ignoreArray)){ 
                          $aMemberships[] = array($aMemb['ID'] => $aMemb['Name']);
                      }
                  }
                  

                  这会打印出正确的字段,但它们是数组内的数组.我需要 foreach 循环来输出一个像这样的简单数组:

                  This prints out the right fields but they are arrays inside arrays. I need the foreach loop to output a simple array like this one:

                  $aMemberships = array('1' => 'Standard', '2' => 'Silver');
                  

                  我做错了什么?

                  推荐答案

                  您需要更改 $aMemberships 分配

                  You need to change your $aMemberships assignment

                  $aMemberships[] = $aMemb['Name']; 
                  

                  如果你想要一个数组

                  $aMemberships[$aMemb['ID']] = $aMemb['Name'];
                  

                  如果你想要地图.

                  你正在做的是将一个数组附加到一个数组中.

                  What you are doing is appending an array to an array.

                  这篇关于从 Foreach Loop PHP 创建关联数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:&quot;as $key =&gt; 之间的区别$值"和“作为 下一篇:PHP - foreach 循环中变量前的 &

                  相关文章

                  最新文章

                • <legend id='JXOUk'><style id='JXOUk'><dir id='JXOUk'><q id='JXOUk'></q></dir></style></legend>

                    <tfoot id='JXOUk'></tfoot>
                  1. <small id='JXOUk'></small><noframes id='JXOUk'>

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