Skip to content

Instantly share code, notes, and snippets.

@stemar
Created January 18, 2023 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stemar/ec0998108af80918cd61956e30927398 to your computer and use it in GitHub Desktop.
Save stemar/ec0998108af80918cd61956e30927398 to your computer and use it in GitHub Desktop.
Recursive array_map()
<?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