Skip to content

Instantly share code, notes, and snippets.

@marcelaraujo
Created February 26, 2015 03:59
Show Gist options
  • Save marcelaraujo/67ee06794753fdcec042 to your computer and use it in GitHub Desktop.
Save marcelaraujo/67ee06794753fdcec042 to your computer and use it in GitHub Desktop.
The most memory-efficient array_map_recursive()
<?php
function array_map_recursive(callable $func, array $arr) {
array_walk_recursive($arr, function(&$v) use ($func) {
$v = $func($v);
});
return $arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment