public static function map(array $array, callable $callback)
    {
        $newArray = [];

        foreach ($array as $key => $item) {
            $result = $callback($item, $key);

            $newArray = is_array($result) ?
                array_replace_recursive($array, $result) :
                array_merge_recursive($array, (array) $result);
        }

        return $newArray;
    }
public static function map(array $array, callable $callback)
    {
        $newArray = [];

        foreach ($array as $key => $item) {
            $result = $callback($item, $key);

            $newArray = is_array($result) ?
                array_replace_recursive($array, $result) :
                array_merge_recursive($array, (array) $result);
        }

        return $newArray;
    }
public static function map ( array $ array , callable $ callback ) { $ newArray = [ ] ; foreach ( $ array as $ key => $ item ) { $ result = $ callback ( $ item , $ key ) ; $ newArray = is_array ( $ result ) ? array_replace_recursive ( $ array , $ result ) : array_merge_recursive ( $ array , ( array ) $ result ) ; } return $ newArray ; }
Applies the callback to the elements of the given arrays

@param array    $array
@param callable $callback

@return array
Applies the callback to the elements of the given arrays