3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: {closure}(): Argument #1 ($value) must be passed by reference, value given in /in/PlKcr on line 9 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 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
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.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 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] => )

preferences:
201.76 ms | 403 KiB | 183 Q