3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $numeric_tests = array( 'test1' => array( '11', '22', '33', '44' ), 'test2' => array( '44', '55', '66', '77' ) ); $assoc_tests = array( 'test1' => array( '11' => '11', '22' => '22', '33' => '33', '44' => '44' ), 'test2' => array( '44' => '44', '55' => '55', '66' => '66', '77' => '77' ) ); $numeric_concat = array(); $numeric_merge = array(); foreach( $numeric_tests as $test ) { $numeric_concat += $test; $numeric_merge = array_merge( $numeric_merge, $test ); } $assoc_concat = array(); $assoc_merge = array(); foreach( $assoc_tests as $test ) { $assoc_concat += array_flip( $test ); $assoc_merge = array_merge( $assoc_merge, $test ); } print_r($numeric_concat); print_r($numeric_merge); print_r($assoc_concat); print_r($assoc_merge);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => 11 [1] => 22 [2] => 33 [3] => 44 ) Array ( [0] => 11 [1] => 22 [2] => 33 [3] => 44 [4] => 44 [5] => 55 [6] => 66 [7] => 77 ) Array ( [11] => 11 [22] => 22 [33] => 33 [44] => 44 [55] => 55 [66] => 66 [77] => 77 ) Array ( [0] => 11 [1] => 22 [2] => 33 [3] => 44 [4] => 44 [5] => 55 [6] => 66 [7] => 77 )