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

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

    3. <legend id='pwleJ'><style id='pwleJ'><dir id='pwleJ'><q id='pwleJ'></q></dir></style></legend>

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

      在 PHP 中的任意位置插入数组中的新项目

      Insert new item in array on any position in PHP(在 PHP 中的任意位置插入数组中的新项目)
    4. <i id='c5gTQ'><tr id='c5gTQ'><dt id='c5gTQ'><q id='c5gTQ'><span id='c5gTQ'><b id='c5gTQ'><form id='c5gTQ'><ins id='c5gTQ'></ins><ul id='c5gTQ'></ul><sub id='c5gTQ'></sub></form><legend id='c5gTQ'></legend><bdo id='c5gTQ'><pre id='c5gTQ'><center id='c5gTQ'></center></pre></bdo></b><th id='c5gTQ'></th></span></q></dt></tr></i><div id='c5gTQ'><tfoot id='c5gTQ'></tfoot><dl id='c5gTQ'><fieldset id='c5gTQ'></fieldset></dl></div>
        <tbody id='c5gTQ'></tbody>

            <legend id='c5gTQ'><style id='c5gTQ'><dir id='c5gTQ'><q id='c5gTQ'></q></dir></style></legend>
          1. <tfoot id='c5gTQ'></tfoot>

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

                <bdo id='c5gTQ'></bdo><ul id='c5gTQ'></ul>
                本文介绍了在 PHP 中的任意位置插入数组中的新项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如何将新项目插入到数组的任意位置,例如在数组的中间?

                解决方案

                您可能会发现这更直观一些.它只需要一个函数调用 array_splice:

                $original = array('a', 'b', 'c', 'd', 'e' );$inserted = array('x');//不一定是数组,见手册引用array_splice($original, 3, 0, $inserted);//在位置 3 处拼接//$original 现在是 a b c x d e

                <块引用>

                如果替换只是一个元素,则无需在其周围放置 array(),除非该元素是数组本身、对象或 NULL.

                <块引用>

                返回值:需要注意的是,该函数返回所需的替换.$original 通过引用传递并就地编辑.在 array &$array 和 &splice.php" rel="nofollow noreferrer">参数列表 .

                How can I insert a new item into an array on any position, for example in the middle of array?

                解决方案

                You may find this a little more intuitive. It only requires one function call to array_splice:

                $original = array( 'a', 'b', 'c', 'd', 'e' );
                $inserted = array( 'x' ); // not necessarily an array, see manual quote
                 
                array_splice( $original, 3, 0, $inserted ); // splice in at position 3
                // $original is now a b c x d e
                

                If replacement is just one element it is not necessary to put array() around it, unless the element is an array itself, an object or NULL.

                RETURN VALUE: To be noted that the function does not return the desired substitution. The $original is passed by reference and edited in place. See the expression array &$array with & in the parameters list .

                这篇关于在 PHP 中的任意位置插入数组中的新项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
              • <tfoot id='59oOx'></tfoot>
                1. <small id='59oOx'></small><noframes id='59oOx'>

                  <legend id='59oOx'><style id='59oOx'><dir id='59oOx'><q id='59oOx'></q></dir></style></legend>

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