public function buildUrl($url, array $query)
	{
		if (empty($query)) {
			return $url;
		}

		$parts = parse_url($url);

		$queryString = '';
		if (isset($parts['query']) && $parts['query']) {
			$queryString .= $parts['query'].'&'.http_build_query($query);
		} else {
			$queryString .= http_build_query($query);
		}

		$retUrl = $parts['scheme'].'://'.$parts['host'];
		if (isset($parts['port'])) {
			$retUrl .= ':'.$parts['port'];
		}

		if (isset($parts['path'])) {
			$retUrl .= $parts['path'];
		}

		if ($queryString) {
			$retUrl .= '?' . $queryString;
		}

		return $retUrl;
	}
public function buildUrl($url, array $query)
	{
		if (empty($query)) {
			return $url;
		}

		$parts = parse_url($url);

		$queryString = '';
		if (isset($parts['query']) && $parts['query']) {
			$queryString .= $parts['query'].'&'.http_build_query($query);
		} else {
			$queryString .= http_build_query($query);
		}

		$retUrl = $parts['scheme'].'://'.$parts['host'];
		if (isset($parts['port'])) {
			$retUrl .= ':'.$parts['port'];
		}

		if (isset($parts['path'])) {
			$retUrl .= $parts['path'];
		}

		if ($queryString) {
			$retUrl .= '?' . $queryString;
		}

		return $retUrl;
	}
public function buildUrl ( $ url , array $ query ) { if ( empty ( $ query ) ) { return $ url ; } $ parts = parse_url ( $ url ) ; $ queryString = '' ; if ( isset ( $ parts [ 'query' ] ) && $ parts [ 'query' ] ) { $ queryString .= $ parts [ 'query' ] . '&' . http_build_query ( $ query ) ; } else { $ queryString .= http_build_query ( $ query ) ; } $ retUrl = $ parts [ 'scheme' ] . '://' . $ parts [ 'host' ] ; if ( isset ( $ parts [ 'port' ] ) ) { $ retUrl .= ':' . $ parts [ 'port' ] ; } if ( isset ( $ parts [ 'path' ] ) ) { $ retUrl .= $ parts [ 'path' ] ; } if ( $ queryString ) { $ retUrl .= '?' . $ queryString ; } return $ retUrl ; }
Build an URL with an optional query string.

@param  string $url   the base URL without any query string
@param  array  $query array of GET parameters

@return string
Build an URL with an optional query string .