Home > Backend Development > PHP Tutorial > array_splice函数使用方法

array_splice函数使用方法

PHP中文网
Release: 2016-06-13 12:38:58
Original
1212 people have browsed it

array_splice() 函数从数组中移除选定的元素,并用新元素取代它。该函数也将返回包含被移除元素的数组。

提示:如果函数没有移除任何元素(length=0),则将从 start 参数的位置插入被替换数组

注释:不保留被替换数组中的键名。

<?php
$a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
$a2=array("a"=>"purple","b"=>"orange");array_splice($a1,0,2,$a2);
print_r($a1);
?>
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