3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = [1, 2, 3, 4]; $callable = function($key, $value) { $value = $value * 100; echo $key.PHP_EOL; }; $newArray = array_map($callable, $array); print_r($newArray);
based on DbGOh
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/KLmXc:4 Stack trace: #0 [internal function]: {closure}(1) #1 /in/KLmXc(9): array_map(Object(Closure), Array) #2 {main} thrown in /in/KLmXc on line 4
Process exited with code 255.
Output for 5.4.10 - 7.0.20
Warning: Missing argument 2 for {closure}() in /in/KLmXc on line 4 Notice: Undefined variable: value in /in/KLmXc on line 5 1 Warning: Missing argument 2 for {closure}() in /in/KLmXc on line 4 Notice: Undefined variable: value in /in/KLmXc on line 5 2 Warning: Missing argument 2 for {closure}() in /in/KLmXc on line 4 Notice: Undefined variable: value in /in/KLmXc on line 5 3 Warning: Missing argument 2 for {closure}() in /in/KLmXc on line 4 Notice: Undefined variable: value in /in/KLmXc on line 5 4 Array ( [0] => [1] => [2] => [3] => )
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/KLmXc on line 3
Process exited with code 255.