$a = array(0 => 'a', 1 => 'b');
$b = array(2 => 'c', 3 => 'd');
$c = $a + $b;
var_dump($c);
echo '<br />';
var_dump(array_merge($a, $b));
|
array(4) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" }
array(4) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" } |
$a = array('a','b');
$b = array('c','d');
$c = $a + $b;
var_dump($c);
echo '<br />';
var_dump(array_merge($a, $b));
|
$a = array('a','b');
$b = array('c','d');
$c = $a + $b;
var_dump($c);
echo '<br />';
var_dump(array_merge($a, $b));
|
array(2) { [0]=> string(1) "a" [1]=> string(1) "b" }
array(4) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" } |
$a = array('aa' => 'a', 'bb' => 'b');
$b = array('cc' => 'c', 'bb' => 'd');
$c = $a + $b;
var_dump($c);
echo '<br />';
var_dump(array_merge($a, $b));
|
array(3) { ["aa"]=> string(1) "a" ["bb"]=> string(1) "b
" ["cc"]=> string(1) "c" }
array(3) { ["aa"]=> string(1) "a" ["bb"]=> string(1) "d" ["cc"]=> string(1) "c" } |