Answers for "WordPress add query string to URL"

PHP
0

WordPress add query string to URL

PHPfunction shapeSpace_add_var($url, $key, $value) {
	
	$url = preg_replace('/(.*)(?|&)'. $key .'=[^&]+?(&)(.*)/i', '$1$2$4', $url .'&');
	$url = substr($url, 0, -1);
	
	if (strpos($url, '?') === false) {
		return ($url .'?'. $key .'='. $value);
	} else {
		return ($url .'&'. $key .'='. $value);
	}
}
Posted by: Guest on November-04-2020
0

WordPress add query string to URL

PHP$url = 'http://example.com/whatever/?hello=world';
shapeSpace_add_var($url, 'goodbye', 'nightclub');
Posted by: Guest on November-04-2020

Code answers related to "WordPress add query string to URL"

Browse Popular Code Answers by Language