Hey All, I am just begining to learn regex functions in PHP. Anyhow I am trying to code a preg_replace function which basically cleans a URL.
What I mean is say a url is index.php?page=hello&list=10&start=4 you pass that URL and say 'list' to the function (shown below) Anyhow I want that to then return index.php?page=hello&start=4 (see how the entire list reference is now gone) Here is what I have come up with so far, though I am yet to test it as I am coding this at work :) function stripUrl($url, $url_strip) { // Check that $url_strip is in the URL if(strpos($url,'?') && strpos($url, $url_strip.'=')) { // Lets clean up the url $url = preg_replace("/\?|&$url_strip=/", "", $url); } return $url; } My problem is that, how do I make the preg_replace stop when it encounters a & in the URL? If anyone could shed some light on this it would be appreciated, - Regards, Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php