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

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

      1. 在 PHP 中获取和删除数组的第一个元素

        时间:2023-10-13

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

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

            1. <legend id='s3sl1'><style id='s3sl1'><dir id='s3sl1'><q id='s3sl1'></q></dir></style></legend>
            2. <tfoot id='s3sl1'></tfoot>
                <bdo id='s3sl1'></bdo><ul id='s3sl1'></ul>

                  本文介绍了在 PHP 中获取和删除数组的第一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在编写一个系统,我需要一个函数来获取和删除数组的第一个元素.这个数组有数字,即

                  Hi I am coding a system in which I need a function to get and remove the first element of the array. This array has numbers i.e.

                  0,1,2,3,4,5

                  0,1,2,3,4,5

                  我如何遍历这个数组并在每次传递时获取值,然后将其从数组中删除,以便在 5 轮结束时数组将为空.

                  how can I loop through this array and with each pass get the value and then remove that from the array so at the end of 5 rounds the array will be empty.

                  提前致谢

                  推荐答案

                  您可以尝试使用 foreach/unset,而不是 array_shift.

                  You might try using foreach/unset, instead of array_shift.

                  $array = array(0, 1, 2, 3, 4, 5);
                  
                  foreach($array as $value)
                  {
                      // with each pass get the value
                      // use method to doSomethingWithValue($value);
                      echo $value;
                      // and then remove that from the array 
                      unset($array[$value]);
                  }
                  //so at the end of 6 rounds the array will be empty
                  assert('empty($array) /* Array must be empty. */');
                  ?>
                  

                  这篇关于在 PHP 中获取和删除数组的第一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP 反射类.如何获取属性的值? 下一篇:PHP 需要并包含 GET

                  相关文章

                  <tfoot id='Uhw4S'></tfoot>

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

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

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