3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = array( 4 => 'a', 'k' => array( 4 => 'a' ) ); $arr2 = array( 5 => 'b', 'k' => array( 5 => 'b' ) ); $arr3 = array_merge_recursive( $arr1, $arr2 ); var_dump( $arr3 );
Output for 4.3.1 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.30, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 8.0.0 - 8.0.12, 8.1rc1 - rc3
array(3) { [0]=> string(1) "a" ["k"]=> array(2) { [4]=> string(1) "a" [5]=> string(1) "b" } [1]=> string(1) "b" }

preferences:
50.26 ms | 463 KiB | 5 Q