3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /* hey, i'm trying to get: Array[1] = Array ( [A1] => 123 [B1] => 1234 [C2] => Array ( [0] => 123 [1] => 456 [2] => 789 ) [R2] => Array ( [0] => 1 [1] => 4 [2] => 4 [3] => 6 ) ) */ $c = array('0' => array(), '1'=>array("A1"=>123,"B1"=>1234,"C2"=>array(123,456,789))); $d = array('0' => array(), '1'=>array("R2"=>array(1,4,4,6))); echo "<h1>now what</h1>"; $y = array_merge_recursive($d,$c); print_r($y);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<h1>now what</h1>Array ( [0] => Array ( ) [1] => Array ( [R2] => Array ( [0] => 1 [1] => 4 [2] => 4 [3] => 6 ) ) [2] => Array ( ) [3] => Array ( [A1] => 123 [B1] => 1234 [C2] => Array ( [0] => 123 [1] => 456 [2] => 789 ) ) )