3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $pattern = [ 'child' => function($age) { return $age < 13; }, 'teen' => function($age) { return $age > 12 && $age < 20; }, 'adult' => function($age) { return $age > 20; } ]; $routines = [ 'child' => function($name) { return 'Hello little '.$name; }, 'teen' => function($name) { return $name.', bro, U fine?'; }, 'adult' => function($age) { return 'Good morning Mr. '.$name; } ]; var_dump(array_map(null, $pattern, $routines));
based on lOJFf
Output for 5.4.0 - 7.2.0
array(3) { [0]=> array(2) { [0]=> object(Closure)#1 (1) { ["parameter"]=> array(1) { ["$age"]=> string(10) "<required>" } } [1]=> object(Closure)#4 (1) { ["parameter"]=> array(1) { ["$name"]=> string(10) "<required>" } } } [1]=> array(2) { [0]=> object(Closure)#2 (1) { ["parameter"]=> array(1) { ["$age"]=> string(10) "<required>" } } [1]=> object(Closure)#5 (1) { ["parameter"]=> array(1) { ["$name"]=> string(10) "<required>" } } } [2]=> array(2) { [0]=> object(Closure)#3 (1) { ["parameter"]=> array(1) { ["$age"]=> string(10) "<required>" } } [1]=> object(Closure)#6 (1) { ["parameter"]=> array(1) { ["$age"]=> string(10) "<required>" } } } }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/YSv04 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/YSv04 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/YSv04 on line 3
Process exited with code 255.