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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:40:321556browse

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>
Statement:
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