3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $base = array("orange", "banana", "apple", "raspberry"); $replacements = array(0 => "pineapple", 4 => "cherry"); $replacements2 = array(0 => "grape"); $basket = array_replace($base, $replacements, $replacements2); print_r($basket); $array1 = array("color" => "red", 2, 4); $array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4); $result = array_merge($array1, $array2); print_r($result); print_r(array_replace($array1, $array2));
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => grape [1] => banana [2] => apple [3] => raspberry [4] => cherry ) Array ( [color] => green [0] => 2 [1] => 4 [2] => a [3] => b [shape] => trapezoid [4] => 4 ) Array ( [color] => green [0] => a [1] => b [shape] => trapezoid [2] => 4 )
Output for 5.0.0 - 5.2.17
Fatal error: Call to undefined function array_replace() in /in/QCisY on line 7
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: array_replace() in /in/QCisY on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: array_replace() in /in/QCisY on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: array_replace() in /in/QCisY on line 7