<?xml version="1.0" encoding="UTF-8" ?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
			<title>Tagged with "url"</title>
			<link>http://www.addedbytes.com/feeds/tag-feed/</link>
			<description></description>
			<language>en</language>
			<copyright>Web Development in Brighton - Added Bytes 2006</copyright>
			<ttl>120</ttl>
			<item>
				<title>PHP Querystring Functions</title>
				<link>http://www.addedbytes.com/blog/code/php-querystring-functions/</link>
				<description><![CDATA[ <p>Adding and removing variables to and from URLs using PHP can be a relatively simple process admittedly, but I have a couple of functions I use often to make the process even less time-consuming.</p><br />
<br />
<h3>Add Querystring Variable</h3><br />
<br />
<p>A PHP function that will add the querystring variable $key with a value $value to $ur</p> <p>Adding and removing variables to and from URLs using PHP can be a relatively simple process admittedly, but I have a couple of functions I use often to make the process even less time-consuming.</p>

<h3>Add Querystring Variable</h3>

<p>A PHP function that will add the querystring variable $key with a value $value to $url. If $key is already specified within $url, it will replace it.</p>

<pre class="php">function add_querystring_var($url, $key, $value) {
    $url = preg_replace('/(.*)(?|&amp;)' . $key . '=[^&amp;]+?(&amp;)(.*)/i', '$1$2$4', $url . '&amp;');
    $url = substr($url, 0, -1);
    if (strpos($url, '?') === false) {
        return ($url . '?' . $key . '=' . $value);
    } else {
        return ($url . '&amp;' . $key . '=' . $value);
    }
}</pre>

<h3>Remove Querystring Variable</h3>

<p>A PHP function that will remove the variable $key and its value from the given $url.</p>

<pre class="php">function remove_querystring_var($url, $key) {
    $url = preg_replace('/(.*)(?|&amp;)' . $key . '=[^&amp;]+?(&amp;)(.*)/i', '$1$2$4', $url . '&amp;');
    $url = substr($url, 0, -1);
    return ($url);
}</pre> <br><br>]]></description>
				<pubDate>Tue, 05 Dec 2006 15:41:30 +0000</pubDate>
				<guid isPermaLink="false">http://www.addedbytes.com/blog/code/php-querystring-functions/</guid>
				<dc:creator>Dave Child</dc:creator>
				<a href="/feeds/tag-feed/?tags=code&amp;start=0" class="ditto_tag" rel="tag">code</a>,<a href="/feeds/tag-feed/?tags=development&amp;start=0" class="ditto_tag" rel="tag">development</a>,<a href="/feeds/tag-feed/?tags=functions&amp;start=0" class="ditto_tag" rel="tag">functions</a>,<a href="/feeds/tag-feed/?tags=links&amp;start=0" class="ditto_tag" rel="tag">links</a>,<a href="/feeds/tag-feed/?tags=php&amp;start=0" class="ditto_tag" rel="tag">php</a>,<a href="/feeds/tag-feed/?tags=programming&amp;start=0" class="ditto_tag" rel="tag">programming</a>,<a href="/feeds/tag-feed/?tags=querystring&amp;start=0" class="ditto_tag" rel="tag">querystring</a>,<a href="/feeds/tag-feed/?tags=reference&amp;start=0" class="ditto_tag" rel="tag">reference</a>,<a href="/feeds/tag-feed/?tags=tips&amp;start=0" class="ditto_tag" rel="tag">tips</a>,<a href="/feeds/tag-feed/?tags=url&amp;start=0" class="ditto_tag" rel="tag">url</a>,<a href="/feeds/tag-feed/?tags=variable&amp;start=0" class="ditto_tag" rel="tag">variable</a>
			</item>
	</channel>
</rss>