The main difference is that if the same key name appears in two or more arrays, the key name is divided into strings or numbers, which requires attention
1 when the key name is a number, the Array_merge () does not overwrite the original value, but the + merge array returns the first occurrence of the value as the final result, while those values that have the same key name in the following array are "discarded" (not overwritten).
2 when the key name is a character, + still returns the first occurrence of the value as the final result, and those values with the same key name in the following array are "discarded", but Array_merge () overrides the value of the same key name as before.
Note that the array key form ' number ' is equivalent to the number
Copy Code code as follows:
$a = Array (' A ', ' B ');
$b = Array (' C ', ' d ');
$c = $a + $b;
Var_dump ($a);
Var_dump (Array_merge ($a, $b));
$a = Array (0 => ' a ', 1 => ' B ');
$b = Array (0 => ' C ', 1 => ' B ');
$c = $a + $b;
Var_dump ($c);
Var_dump (Array_merge ($a, $b));
$a = Array (' A ', ' B ');
$b = Array (' 0 ' => ' C ', 1 => ' B ');
$c = $a + $b;
Var_dump ($c);
Var_dump (Array_merge ($a, $b));
$a = Array (0 => ' a ', 1 => ' B ');
$b = Array (' 0 ' => ' C ', ' 1 ' => ' B ');
$c = $a + $b;
Var_dump ($c);
Var_dump (Array_merge ($a, $b));
Results
Copy Code code as follows:
Array
0 => string ' a ' (length=1)
1 => string ' B ' (length=1)
2 => string ' C ' (length=1)
3 => string ' d ' (length=1)
Array
0 => string ' a ' (length =1)
1 => string ' B ' (length=1)
Array
0 => string ' a ' (length=1)
1 => string ' B ' (le ngth=1)
2 => string ' C ' (length=1)
3 => string ' B ' (length=1)
Array
0 => string ' a ' (length=1)
1 => string ' B ' (length=1)
Array
0 => string ' a ' (length=1)
1 => string ' B ' (length=1
2 => string ' C ' (length=1)
3 => string ' B ' (length=1)
Array
0 => string ' a ' (Leng th=1)
1 => string ' B ' (length=1)
Array
0 => string ' a ' (length=1)
1 => string ' B ' ( length=1)
2 => string ' C ' (length=1)
3 => string ' B ' (length=1)