Last active
January 30, 2021 14:48
-
-
Save ravishakya/aec83c56b54ae96da8bdfb2b28c4073a to your computer and use it in GitHub Desktop.
array_map for multidimensional array
This file contains 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
function multidimentional_array_map( $function, $arr ){ | |
$result = array(); | |
foreach ($arr as $key => $val){ | |
$result[$key] = (is_array($val) ? multidimentional_array_map($function, $val) : $function($val)); | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment