src/Url/UrlUtil.php
public function addQueryString($query, $url = null)
    {
        $queryString = '';
        $url = static::prepareUrl($url);
        $query = trim(ampersand($query, false), '&');

        $explodedUrl = explode('?', $url, 2);

        if (2 === \count($explodedUrl)) {
            list($script, $queryString) = $explodedUrl;
        } else {
            list($script) = $explodedUrl;
        }

        parse_str($queryString, $queries);

        $queries = array_filter($queries);
        unset($queries['language']);

        $href = '';

        if (!empty($queries)) {
            parse_str($query, $new);
            $href = '?'.http_build_query(array_merge($queries, $new), '', '&');
        } elseif (!empty($query)) {
            $href = '?'.$query;
        }

        return $script.$href;
    }
public function addQueryString($query, $url = null)
    {
        $queryString = '';
        $url = static::prepareUrl($url);
        $query = trim(ampersand($query, false), '&');

        $explodedUrl = explode('?', $url, 2);

        if (2 === \count($explodedUrl)) {
            list($script, $queryString) = $explodedUrl;
        } else {
            list($script) = $explodedUrl;
        }

        parse_str($queryString, $queries);

        $queries = array_filter($queries);
        unset($queries['language']);

        $href = '';

        if (!empty($queries)) {
            parse_str($query, $new);
            $href = '?'.http_build_query(array_merge($queries, $new), '', '&');
        } elseif (!empty($query)) {
            $href = '?'.$query;
        }

        return $script.$href;
    }
public function addQueryString ( $ query , $ url = null ) { $ queryString = '' ; $ url = static :: prepareUrl ( $ url ) ; $ query = trim ( ampersand ( $ query , false ) , '&' ) ; $ explodedUrl = explode ( '?' , $ url , 2 ) ; if ( 2 === \ count ( $ explodedUrl ) ) { list ( $ script , $ queryString ) = $ explodedUrl ; } else { list ( $ script ) = $ explodedUrl ; } parse_str ( $ queryString , $ queries ) ; $ queries = array_filter ( $ queries ) ; unset ( $ queries [ 'language' ] ) ; $ href = '' ; if ( ! empty ( $ queries ) ) { parse_str ( $ query , $ new ) ; $ href = '?' . http_build_query ( array_merge ( $ queries , $ new ) , '' , '&' ) ; } elseif ( ! empty ( $ query ) ) { $ href = '?' . $ query ; } return $ script . $ href ; }
Add a query string to the given URI string or page ID.

@param string $query
@param mixed  $url

@throws \InvalidArgumentException

@return string
Add a query string to the given URI string or page ID .