3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = array(10, 11, 12); $b = array(20, 21, 22, 23); $c = array('a' => 'a', 'b' => 'b', 'c' => 'c'); $d = array('v' => 'v', 'x' => 'x', 'y' => 'y', 'z' => 'z'); $r10 = $a + $b; $r11 = $b + $a; $r12 = array_merge($a, $b); $r13 = array_merge($b, $a); $r20 = $c + $d; $r21 = $d + $c; $r22 = array_merge($c, $d); $r23 = array_merge($d, $c); // a + b var_dump($r10); //b + a var_dump($r11); // m a b var_dump($r12); // m b a var_dump($r13); var_dump($r20); var_dump($r21); var_dump($r22); var_dump($r23);
based on Oc1KZ
Output for 4.3.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(4) { [0]=> int(10) [1]=> int(11) [2]=> int(12) [3]=> int(23) } array(4) { [0]=> int(20) [1]=> int(21) [2]=> int(22) [3]=> int(23) } array(7) { [0]=> int(10) [1]=> int(11) [2]=> int(12) [3]=> int(20) [4]=> int(21) [5]=> int(22) [6]=> int(23) } array(7) { [0]=> int(20) [1]=> int(21) [2]=> int(22) [3]=> int(23) [4]=> int(10) [5]=> int(11) [6]=> int(12) } array(7) { ["a"]=> string(1) "a" ["b"]=> string(1) "b" ["c"]=> string(1) "c" ["v"]=> string(1) "v" ["x"]=> string(1) "x" ["y"]=> string(1) "y" ["z"]=> string(1) "z" } array(7) { ["v"]=> string(1) "v" ["x"]=> string(1) "x" ["y"]=> string(1) "y" ["z"]=> string(1) "z" ["a"]=> string(1) "a" ["b"]=> string(1) "b" ["c"]=> string(1) "c" } array(7) { ["a"]=> string(1) "a" ["b"]=> string(1) "b" ["c"]=> string(1) "c" ["v"]=> string(1) "v" ["x"]=> string(1) "x" ["y"]=> string(1) "y" ["z"]=> string(1) "z" } array(7) { ["v"]=> string(1) "v" ["x"]=> string(1) "x" ["y"]=> string(1) "y" ["z"]=> string(1) "z" ["a"]=> string(1) "a" ["b"]=> string(1) "b" ["c"]=> string(1) "c" }