public static function Openlayers::array_map_recursive in Openlayers 7.3
Apply a function recursively to all the value of an array.
Parameters
callable $func: Function to call.
array $arr: The array to process.
Return value
array The processed array
1 call to Openlayers::array_map_recursive()
- Base::getExport in src/
Types/ Base.php - Return an object, CTools Exportable.
File
- src/
Openlayers.php, line 297 - Contains Openlayers.
Class
- Openlayers
- Class Openlayers.
Namespace
Drupal\openlayersCode
public static function array_map_recursive($func, array $arr) {
/*
// This is the PHP Version >= 5.5
// $func must be a callable.
array_walk_recursive($arr, function(&$v) use ($func) {
$v = $func($v);
});
return $arr;
*/
foreach ($arr as $key => $value) {
if (is_array($arr[$key])) {
$arr[$key] = self::array_map_recursive($func, $arr[$key]);
}
else {
$arr[$key] = call_user_func($func, $arr[$key]);
}
}
return $arr;
}