Last active
July 28, 2021 16:16
-
-
Save jakzal/07144f06b5ab73be0fdab0a5c641ded0 to your computer and use it in GitHub Desktop.
Flat map in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function flat_map(callable $callback, array $collection) { | |
return array_merge([], ...array_map($callback, $collection)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test: https://3v4l.org/qQNTv