3v4l.org

run code in 300+ PHP versions simultaneously
<?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);
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
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.5.24 - 5.5.35, 5.6.8 - 5.6.21, 7.0.0 - 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] => )

preferences:
178.86 ms | 403 KiB | 182 Q