1. array array_merge(array $array1[, array $...])
Merge the elements of one or more arrays, append the following elements to the previous elements, and return the resulting array.
Code:
$arr1 = array( 'astr1' => 'astr1', 3 => 'anum1' ); $arr2 = array( 1 => 'bnum1', 2 => 'bnum2', 'bstr1' => 'bstr1', 3 => 'bnum3', 'astr1' => 'bstr2', '0' => 'bstr3', '1' => 'bstr4' ); print_r(array_merge($arr1, $arr2));
Result:
Array ( [astr1] => bstr2 [0] => anum1 [1] => bstr4 [2] => bnum2 [bstr1] => bstr1 [3] => bnum3 [4] => bstr3 )
Conclusion:
Elements whose key is a numeric value are reordered according to increasing rules starting from key=0. If there are duplicate key values, they are still sorted in increasing order;
Key is the element of the string, arranged in the original order. If there is a duplicate key, the subsequent value will overwrite the previous value;
When the key is ‘0’, it is processed as numbers; when the key is ‘1’, ‘2’ and other numeric strings, the previous values of key 1 and 2 will be overwritten