First look at the array elements:
<?php$a = Array (' R ' =>1,2,3,4); Var_dump (' A ', $a); $b = Array (' R ' =>5,6,7,8); Var_dump (' B ', $b); $c = Array (' r ' = >5,6,7,8,9) var_dump (' C ', $c) var_dump (' a+b ', $a + $b) var_dump (' a+c ', $a + $c) var_dump (' Amb ', array_merge ($a, $b)) ; Var_dump (' AMC ', Array_merge ($a, $c));
Second look at the output:
string ' A ' (length=1) array ' R ' => int 1 0 => int 2 1 => int 3 2 => int 4string ' B ' (length=1) array ' R ' => int 5 0 => int 6 1 => int 7 2 => int 8string ' C ' (length=1) array ' R ' => int 5 0 => int 6 1 => int 7 2 => int 8 3 => int 9string ' A +b ' (length=3) array ' R ' => int 1 0 => int 2 1 => int 3 2 => int 4string ' a+c ' (length =3) array ' R ' => int 1 0 => int 2 1 = > int 3 2 => int 4 3 => int 9string ' Amb ' (length=3) array ' R ' => int 5 0 => int 2 1 = > int 3 2 => int 4 3 => int 6 4 => int 7 5 => int 8string ' AMC ' (length=3) array ' R ' => int 5 0 => int 2 1 = > int 3 2 => int 4 3 => int 6 4 => int 7 5 => int 8 6 => int 9
Conclusion: Combine the array with plus sign: Consider both the key-value pairs of the numeric indexes, the key-value pairs of the string indexes, and the values of the key-names in the front arrays.
Merge the array with Array_merge (): Only consider the key-value pairs of the string index, overwrite the value of the previous array with the same key name, and the value of the numeric index is not overwritten while preserving
Also: Array_merge () will rearrange the number index of two arrays, "+" does not
PHP number combinations with Plus and array_merge () differences