3v4l.org

run code in 200+ PHP versions simultaneously
<?php $array1 = array( 'k' => array( 2 => 100, 98 => 200, ) ); $array2 = array( 'k' => array( 64 => 300 ) ); $array3 = array_merge_recursive( $array1, $array2 ); echo '<pre>'; var_dump( $array3 ); echo 'count: '.count( $array3['k'] );
Output for 7.0.0 - 7.1.17, 7.2.0 - 7.2.6
<pre>array(1) { ["k"]=> array(3) { [2]=> int(100) [98]=> int(200) [2]=> int(300) } } count: 3
Output for 4.3.0 - 5.6.30, 7.1.20
<pre>array(1) { ["k"]=> array(3) { [2]=> int(100) [98]=> int(200) [99]=> int(300) } } count: 3