久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

      <i id='FxE35'><tr id='FxE35'><dt id='FxE35'><q id='FxE35'><span id='FxE35'><b id='FxE35'><form id='FxE35'><ins id='FxE35'></ins><ul id='FxE35'></ul><sub id='FxE35'></sub></form><legend id='FxE35'></legend><bdo id='FxE35'><pre id='FxE35'><center id='FxE35'></center></pre></bdo></b><th id='FxE35'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='FxE35'><tfoot id='FxE35'></tfoot><dl id='FxE35'><fieldset id='FxE35'></fieldset></dl></div>

        <tfoot id='FxE35'></tfoot>

        獲取 foreach 循環中的下一個元素

        Get next element in foreach loop(獲取 foreach 循環中的下一個元素)

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

            <tbody id='gdRFv'></tbody>
            <tfoot id='gdRFv'></tfoot>
          • <small id='gdRFv'></small><noframes id='gdRFv'>

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

                  本文介紹了獲取 foreach 循環中的下一個元素的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個 foreach 循環,我想查看循環中是否有下一個元素,以便我可以將當??前元素與下一個元素進行比較.我怎樣才能做到這一點?我已經閱讀了 current 和 next 函數,但我不知道如何使用它們.

                  I have a foreach loop and I want to see if there is a next element in the loop so I can compare the current element with the next. How can I do this? I've read about the current and next functions but I can't figure out how to use them.

                  提前致謝

                  推薦答案

                  一種獨特的方法是反轉數組和 then 循環.這也適用于非數字索引數組:

                  A unique approach would be to reverse the array and then loop. This will work for non-numerically indexed arrays as well:

                  $items = array(
                      'one'   => 'two',
                      'two'   => 'two',
                      'three' => 'three'
                  );
                  $backwards = array_reverse($items);
                  $last_item = NULL;
                  
                  foreach ($backwards as $current_item) {
                      if ($last_item === $current_item) {
                          // they match
                      }
                      $last_item = $current_item;
                  }
                  

                  如果您仍然對使用 currentnext 函數感興趣,您可以這樣做:

                  If you are still interested in using the current and next functions, you could do this:

                  $items = array('two', 'two', 'three');
                  $length = count($items);
                  for($i = 0; $i < $length - 1; ++$i) {
                      if (current($items) === next($items)) {
                          // they match
                      }
                  }
                  

                  #2 可能是最好的解決方案.注意,$i <$length - 1; 將在比較數組中的最后兩項后停止循環.我把它放在循環中,以便在示例中明確.你應該只計算 $length = count($items) - 1;

                  #2 is probably the best solution. Note, $i < $length - 1; will stop the loop after comparing the last two items in the array. I put this in the loop to be explicit with the example. You should probably just calculate $length = count($items) - 1;

                  這篇關于獲取 foreach 循環中的下一個元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)

                  • <small id='W1i87'></small><noframes id='W1i87'>

                        <tbody id='W1i87'></tbody>
                      <tfoot id='W1i87'></tfoot>

                      <i id='W1i87'><tr id='W1i87'><dt id='W1i87'><q id='W1i87'><span id='W1i87'><b id='W1i87'><form id='W1i87'><ins id='W1i87'></ins><ul id='W1i87'></ul><sub id='W1i87'></sub></form><legend id='W1i87'></legend><bdo id='W1i87'><pre id='W1i87'><center id='W1i87'></center></pre></bdo></b><th id='W1i87'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='W1i87'><tfoot id='W1i87'></tfoot><dl id='W1i87'><fieldset id='W1i87'></fieldset></dl></div>

                        • <legend id='W1i87'><style id='W1i87'><dir id='W1i87'><q id='W1i87'></q></dir></style></legend>
                            <bdo id='W1i87'></bdo><ul id='W1i87'></ul>
                          • 主站蜘蛛池模板: 一级片在线免费看 | 毛片免费看 | 精品久久久久久 | 亚洲免费毛片 | 91精品国产一区二区 | 视频一区二区三区中文字幕 | 日韩高清一区二区 | 99久久久国产精品 | 国产黄色网址在线观看 | 欧美精品一区二区三区在线四季 | 日韩午夜激情 | 日本特黄特色aaa大片免费 | 久久天天综合 | 欧美日韩国产一区二区三区 | 国产美女永久免费无遮挡 | 99久久夜色精品国产亚洲96 | 成人在线观看免费视频 | 日本久久精品 | 本地毛片| 欧美精品久久久久久久久久 | 亚洲一区二区视频 | 国产乱码精品一区二区三区五月婷 | 综合色婷婷 | 国产欧美日韩一区 | h在线| 在线国产一区二区 | 欧美性大战久久久久久久蜜臀 | 中文字字幕一区二区三区四区五区 | 中文字幕久久精品 | 午夜三级视频 | 国产成人久久 | 99国产精品一区二区三区 | 国产精品av久久久久久久久久 | 国产精品国产精品国产专区不蜜 | a级在线免费观看 | 久久久久免费观看 | 国产成人免费视频网站高清观看视频 | 成年人网站免费视频 | 一区二区三区视频在线 | 玖玖综合在线 | 亚洲国产看片 |