3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function arrayReplace($a1, $a2) { foreach($a2 as $k=>$v) { $a1[$k]=$v; } return $a1; } $a1 = array(0 => 1, 1 => "b", 3 => "carrot"); $a2 = array(1 => "c", 2 => "d", 3 => "apple"); print_r(arrayReplace($a1, $a2));
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => 1 [1] => c [3] => apple [2] => d )