3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = array('1'=>'a1','2'=>'a2','a'=>'1'); $b = array('2'=>'b2','b'=>'2'); var_dump($a+$b); var_dump($b+$a); var_dump(array_merge($a,$b)); var_dump(array_merge($b,$a));
based on crHgt
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
array(4) { [1]=> string(2) "a1" [2]=> string(2) "a2" ["a"]=> string(1) "1" ["b"]=> string(1) "2" } array(4) { [2]=> string(2) "b2" ["b"]=> string(1) "2" [1]=> string(2) "a1" ["a"]=> string(1) "1" } array(5) { [0]=> string(2) "a1" [1]=> string(2) "a2" ["a"]=> string(1) "1" [2]=> string(2) "b2" ["b"]=> string(1) "2" } array(5) { [0]=> string(2) "b2" ["b"]=> string(1) "2" [1]=> string(2) "a1" [2]=> string(2) "a2" ["a"]=> string(1) "1" }