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

array_splice函数使用方法

PHP中文网
PHP中文网Original
2016-06-13 12:38:581214browse

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);
?>


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