Search
 
SCRIPT & CODE EXAMPLE
 

PHP

WordPress add query string to URL

PHP$url = 'http://example.com/whatever/?hello=world';
shapeSpace_add_var($url, 'goodbye', 'nightclub');
Comment

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);
	}
}
Comment

PREVIOUS NEXT
Code Example
Php :: php wait for exec to finish 
Php :: PHP parse_str — Parses the string into variables 
Php :: creating jobs laravel 
Php :: PHPDoc @method 
Php :: PHP script to download all images from URL 
Php :: how to create module in laravel 
Php :: socket io laravel 
Php :: yii2 oauth2 
Php :: query builder laravel 
Php :: login as user in laravel from admin panel 
Php :: parameter to laravel seeder 
Php :: laravel run command 
Php :: package manifest php error 
Php :: laravel seeder update 
Php :: PHP if...else...elseif Statements 
Php :: filter value in array php return single value 
Php :: Write Multi-Line Strings in PHP 
Php :: php print number 
Php :: laravel default rate limit 
Php :: Array (key and value) 
Php :: phpspreadsheet 
Php :: placeholder for select php 
Php :: yii2 change transport 
Php :: php pass byref 
Php :: utf8mb4 decode in php 
Php :: how to register a file in a config in laravel 
Php :: check if product has crosssell woocommerce 
Php :: how to fetch data from two tables in mysqli using php 
Php :: form validation in php 
Php :: phpdoc array of strings 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =