久久久久久久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>
                          • 主站蜘蛛池模板: 成人av高清在线观看 | h在线看 | 国产激情网 | 欧美日韩专区 | 成人欧美一区二区三区黑人孕妇 | 欧美一区二区在线播放 | 成人在线视频观看 | 一区二区伦理电影 | 毛片网站在线观看 | 一级片网址 | 国产亚洲精品久久午夜玫瑰园 | 亚洲欧美一区二区三区1000 | 欧美精品在线免费观看 | 久久大陆 | 国产精品久久久久久久久久久久午夜片 | 国产精品久久久亚洲 | 国产福利在线 | 欧美日韩在线成人 | 欧美激情精品久久久久久变态 | 久草在线视频中文 | av黄色在线| 久久99视频精品 | 国产目拍亚洲精品99久久精品 | 久久国产日本 | 欧美激情综合网 | 精品国产一区二区三区免费 | 亚洲国产精品美女 | 亚洲精品成人 | 91一区二区| 欧美精品一区在线发布 | 日本污视频 | 日本电影韩国电影免费观看 | 日韩久草 | av电影一区二区 | 欧美中文在线 | 特黄色一级毛片 | 精品自拍视频在线观看 | 午夜寂寞福利视频 | 国产一区二区三区亚洲 | 久久久精彩视频 | 国产三级日本三级 |