Skip to content

Instantly share code, notes, and snippets.

@alixaxel
Forked from italolelis/flatMap.php
Created January 23, 2016 16:16
Show Gist options
  • Save alixaxel/d8fc7f6984a8099ab86f to your computer and use it in GitHub Desktop.
Save alixaxel/d8fc7f6984a8099ab86f to your computer and use it in GitHub Desktop.
FlatMap implementation in PHP, following the Reactive Extensions intiative
function flatMap($data, \Closure $p)
{
$collection = call_user_func_array("array_map", array($p));
return iterator_to_array(new \RecursiveIteratorIterator(
new \RecursiveArrayIterator($data)), false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment