Revision: 8274
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 11, 2008 09:54 by DaveChild
Initial Code
function add_querystring_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); } } function remove_querystring_var($url, $key) { $url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); $url = substr($url, 0, -1); return ($url); }
Initial URL
http://www.addedbytes.com/php/querystring-functions/
Initial Description
Initial Title
PHP Add and Remove Querystring Variables
Initial Tags
Initial Language
PHP