1 $ arr1array (1, 2, 3, 4, & amp; #39; color & amp; #39; & amp; gt; & amp; #39; red & amp; #39;); 2 $ arr2array (& amp; #39; a & amp; #39;, & amp; #39; B & amp; #39;, & amp; #39; c & amp; #39;, & amp; #39; color & amp; #39; & amp; gt; & amp; #39; blue & amp; #39;); 3print_r (array_merge ($ arr1, $ ar 1 $ arr1 = array (1, 2, 3, 4, 'color' => 'red '); 2 $ arr2 = array ('A', 'B', 'C', 'color' => 'blue'); 3 print_r (array_merge ($ arr1, $ arr2); // The value of the index with the same name will overwrite 4 print_r (array_merge_recursi Ve ($ arr1, $ arr2); // the same key name will not be overwritten. if a single element is converted into a one-dimensional array, both functions are used to merge arrays. The parameter can be 1 to n arrays. (Er, I don't know what to use when the parameter is an array. Who knows to tell me .) Output result: row 3rd: Array ([0] => 1 &
1. Detailed introduction to the array_merge_recursive function
Introduction: The array_merge () function combines arrays and returns a Union array. The obtained array starts with the first input array parameter and is immediately added according to the order in which the following array parameters appear. The format is: 1 array array_merge (array array1 array2 ..., ArrayN) combines the units of one or more arrays. the values of an array are appended to the previous array. Returns an array of results. If the input array contains the same string key name, the key name is followed...
10. common array functions in php (7) array merging array_merge () and array_merge_recursive ()
Introduction: common array functions in php (7) array merging array_merge () and array_merge_recursive ()
[Related Q & A recommendations ]:
In laravel-php, how does one splice this data type in a function?
Php-question about adding a function to array_merge in a loop
Php foreach array_merge problems and confusions
Suspect: A bug in php array_merge_recursive
Thinkphp-php array merge
The above is the article about php array_merge () function. we recommend 10 articles in detail. For more information, see other related articles in the first PHP community!