public static function map($function, $array): array
    {
        $result = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $result[$key] = self::map($function, $value);
            } else {
                $result[$key] = $function($value);
            }
        }

        return $result;
    }
public static function map($function, $array): array
    {
        $result = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $result[$key] = self::map($function, $value);
            } else {
                $result[$key] = $function($value);
            }
        }

        return $result;
    }
public static function map ( $ function , $ array ) : array { $ result = [ ] ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ result [ $ key ] = self :: map ( $ function , $ value ) ; } else { $ result [ $ key ] = $ function ( $ value ) ; } } return $ result ; }
Recursive array mapping

@param \Closure $function
@param array    $array
@return array
Recursive array mapping