private function setQueryParameter($url, $key, $value) {
		$originalQuery     = parse_url($url, PHP_URL_QUERY);
		$decodedQuery      = urldecode($originalQuery);
		$originalIsEncoded = ($decodedQuery !== $originalQuery);
		
		$originalParameters = [];
		parse_str($decodedQuery, $originalParameters);
		
		$newParameters = [];
		parse_str($key.'='.$value, $newParameters);
		
		$fullParameters = array_replace_recursive($originalParameters, $newParameters);
		
		$newQuery = http_build_query($fullParameters);
		if ($originalIsEncoded === false) {
			$newQuery = urldecode($newQuery);
		}
		
		$newUrl = str_replace($originalQuery, $newQuery, $url);
		
		return $newUrl;
	}
private function setQueryParameter($url, $key, $value) {
		$originalQuery     = parse_url($url, PHP_URL_QUERY);
		$decodedQuery      = urldecode($originalQuery);
		$originalIsEncoded = ($decodedQuery !== $originalQuery);
		
		$originalParameters = [];
		parse_str($decodedQuery, $originalParameters);
		
		$newParameters = [];
		parse_str($key.'='.$value, $newParameters);
		
		$fullParameters = array_replace_recursive($originalParameters, $newParameters);
		
		$newQuery = http_build_query($fullParameters);
		if ($originalIsEncoded === false) {
			$newQuery = urldecode($newQuery);
		}
		
		$newUrl = str_replace($originalQuery, $newQuery, $url);
		
		return $newUrl;
	}
private function setQueryParameter ( $ url , $ key , $ value ) { $ originalQuery = parse_url ( $ url , PHP_URL_QUERY ) ; $ decodedQuery = urldecode ( $ originalQuery ) ; $ originalIsEncoded = ( $ decodedQuery !== $ originalQuery ) ; $ originalParameters = [ ] ; parse_str ( $ decodedQuery , $ originalParameters ) ; $ newParameters = [ ] ; parse_str ( $ key . '=' . $ value , $ newParameters ) ; $ fullParameters = array_replace_recursive ( $ originalParameters , $ newParameters ) ; $ newQuery = http_build_query ( $ fullParameters ) ; if ( $ originalIsEncoded === false ) { $ newQuery = urldecode ( $ newQuery ) ; } $ newUrl = str_replace ( $ originalQuery , $ newQuery , $ url ) ; return $ newUrl ; }
add or adjust a key in the query string of a url

@param string $url
@param string $key
@param string $value
add or adjust a key in the query string of a url