3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mapped = array_map(function($a) { return $a * 2; }, (function() { yield "foo" => 1; yield "bar" => 21; })()); var_dump($mapped);
Output for 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, Generator given in /in/74VZY:3 Stack trace: #0 /in/74VZY(3): array_map(Object(Closure), Object(Generator)) #1 {main} thrown in /in/74VZY on line 3
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, Generator given in /in/74VZY:8 Stack trace: #0 /in/74VZY(8): array_map(Object(Closure), Object(Generator)) #1 {main} thrown in /in/74VZY on line 8
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: array_map(): Expected parameter 2 to be an array, object given in /in/74VZY on line 8 NULL
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
Warning: array_map(): Argument #2 should be an array in /in/74VZY on line 8 NULL
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Parse error: syntax error, unexpected '(' in /in/74VZY on line 8
Process exited with code 255.

preferences:
146.82 ms | 402 KiB | 215 Q