public static function modifyQuery($uri, array $newQueryParams)
    {
        if ($uri === null) {
            $uri = static::getCurrentRequestUri();
        }

        $query = parse_url($uri, PHP_URL_QUERY);

        $queryParams = [];
        parse_str($query, $queryParams);

        $newQuery = http_build_query(array_merge($queryParams, $newQueryParams));

        $fragment = parse_url($uri, PHP_URL_FRAGMENT);
        return parse_url($uri, PHP_URL_PATH)
        . ($newQuery ? '?' . $newQuery : '')
        . ($fragment ? '#' . $fragment : '');
    }
public static function modifyQuery($uri, array $newQueryParams)
    {
        if ($uri === null) {
            $uri = static::getCurrentRequestUri();
        }

        $query = parse_url($uri, PHP_URL_QUERY);

        $queryParams = [];
        parse_str($query, $queryParams);

        $newQuery = http_build_query(array_merge($queryParams, $newQueryParams));

        $fragment = parse_url($uri, PHP_URL_FRAGMENT);
        return parse_url($uri, PHP_URL_PATH)
        . ($newQuery ? '?' . $newQuery : '')
        . ($fragment ? '#' . $fragment : '');
    }
public static function modifyQuery ( $ uri , array $ newQueryParams ) { if ( $ uri === null ) { $ uri = static :: getCurrentRequestUri ( ) ; } $ query = parse_url ( $ uri , PHP_URL_QUERY ) ; $ queryParams = [ ] ; parse_str ( $ query , $ queryParams ) ; $ newQuery = http_build_query ( array_merge ( $ queryParams , $ newQueryParams ) ) ; $ fragment = parse_url ( $ uri , PHP_URL_FRAGMENT ) ; return parse_url ( $ uri , PHP_URL_PATH ) . ( $ newQuery ? '?' . $ newQuery : '' ) . ( $ fragment ? '#' . $ fragment : '' ) ; }
Modifies query string and returns updated request part of the URI.

@param string|null $uri
@param array $newQueryParams
@return string
Modifies query string and returns updated request part of the URI .