3v4l.org

run code in 200+ 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 - 7.1.7
Array ( [0] => 1 [1] => c [3] => apple [2] => d )