Home > Backend Development > PHP Tutorial > 怎样对数组进行插入操作,然后后面的数组按顺序往后移?

怎样对数组进行插入操作,然后后面的数组按顺序往后移?

WBOY
Release: 2016-06-06 20:40:32
Original
1550 people have browsed it

array("a","b","c","d")
怎样在b,c的中间插入一个值,并且c,d对应的键值自加1;

回复内容:

array("a","b","c","d")
怎样在b,c的中间插入一个值,并且c,d对应的键值自加1;

<code><?php // http://3v4l.org/KWaTf
$arr = array("a","b","c","d");

array_splice($arr, 2, 0, "1");
print_r($arr);
</code></code>
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template