note 28809 deleted from function.parse-url by didou

From: Date: Sat, 03 Feb 2007 03:10:16 +0000
Subject: note 28809 deleted from function.parse-url by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-122622@lists.php.net to get a copy of this message
Note Submitter: steve at mg-rover dot org ---- An alternative and more straightforward to the remove an argument from a URL code above is below. I'm not saying its any better than the one above, but its easier to read ;) :p ---------------- function RemoveArgFromURL($URL,$Arg) { $Pos = strpos($URL,"$Arg="); if ($Pos) { if ($URL[$Pos-1] == "&") { // If Pos-1 is pointing to a '&' knock Pos back 1 so its removed. $Pos--; } $nMax = strlen($URL); $nEndPos = strpos($URL,"&",$Pos+1); if ($nEndPos === false) { // $Arg is on the end of the URL $URL = substr($URL,0,$Pos); } else { // $Arg is in the URL $URL = str_replace(substr($URL,$Pos,$nEndPos-$Pos),'',$URL); } } return $URL; } ----------------

« previous php.notes (#122622) next »