3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = [1, 2, 3, 4]; $callable = function(&$value, $key) { $value = $value * 100; echo $key.PHP_EOL; }; $newArray = array_map($callable, $array); print_r($newArray);
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed and exactly 2 expected in /in/PlKcr:4 Stack trace: #0 [internal function]: {closure}(1) #1 /in/PlKcr(9): array_map(Object(Closure), Array) #2 {main} thrown in /in/PlKcr on line 4
Process exited with code 255.
Output for 5.4.10 - 7.0.20
Warning: Missing argument 2 for {closure}() in /in/PlKcr on line 4 Notice: Undefined variable: key in /in/PlKcr on line 6 Warning: Missing argument 2 for {closure}() in /in/PlKcr on line 4 Notice: Undefined variable: key in /in/PlKcr on line 6 Warning: Missing argument 2 for {closure}() in /in/PlKcr on line 4 Notice: Undefined variable: key in /in/PlKcr on line 6 Warning: Missing argument 2 for {closure}() in /in/PlKcr on line 4 Notice: Undefined variable: key in /in/PlKcr on line 6 Array ( [0] => [1] => [2] => [3] => )
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/PlKcr on line 3
Process exited with code 255.