Created
January 18, 2023 07:17
-
-
Save stemar/ec0998108af80918cd61956e30927398 to your computer and use it in GitHub Desktop.
Recursive array_map()
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 array_map_recursive($callback, $array) { | |
$func = function ($item) use (&$func, &$callback) { | |
return is_array($item) ? array_map($func, $item) : call_user_func($callback, $item); | |
}; | |
return array_map($func, $array); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment