Home  >  Article  >  Backend Development  >  php-Arrays function-array_merge-merge one or more arrays_PHP tutorial

php-Arrays function-array_merge-merge one or more arrays_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:51:13977browse

array_merge() merges one or more arrays

【Function】
This function combines the elements of one or more arrays. The values ​​in one array are appended to the previous array.
                                                        Return the array as the result. If the input arrays have the same string key names, these values ​​will be overwritten to the previous
Value. However, if the array contains the same numeric key name, the latter value will not overwrite the original value, and
is appended to the back. If only an array is given, and the array is numerically indexed, the key names will be re-indexed in a consecutive manner
【Scope of use】
​​​​​ php4, php5.
【Use】
array array_merge( array array1[,array array2[,array...]] )
           arrayn/required/array to be used for merging
【Example】
[php]


$arr1 = array("color"=>array("favorite"=>"red"),5); 
$arr2 = array(10,"color"=>array("favorite"=>"green","blue"));
var_dump(array_merge($arr1));
/*
array(2) {
["color"]=>
array(1) {
["favorite"]=>
String(3) "red"
}
[0]=>
int(5)
}
*/


Excerpted from zuodefeng’s notes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478216.htmlTechArticlearray_merge() Merge one or more arrays [Function] This function merges the units of one or more arrays , the values ​​in one array are appended to the previous array. Return as...
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