3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function flatMap (array $array, callable $function): array { $output = []; foreach ($array as $value) { $tmp = $function($value); foreach ($tmp as $row) { $output[] = $row; } } return $output; } $example = [ ['schools' => '001|002|003'], ['schools' => '004|005|006'], ['schools' => '007|008|009'], ]; print_r( flatMap($example, function ($record) { return explode('|', $record['schools']); }) );
based on X2AqR
Output for hhvm-3.12.14 - 3.17.3, 7.0.0 - 7.3.0beta1
Array ( [0] => 001 [1] => 002 [2] => 003 [3] => 004 [4] => 005 [5] => 006 [6] => 007 [7] => 008 [8] => 009 )
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting '{' in /in/95qoJ on line 3
Process exited with code 255.