note 28809 added to function.parse-url
| From: | steve at mg-rover dot org | Date: | Fri, 24 Jan 2003 15:59:56 +0000 |
| Subject: | note 28809 added to function.parse-url | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42694@lists.php.net to get a copy of this message | ||
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;
}
----------------
--
http://www.php.net/manual/en/function.parse-url.php
http://master.php.net/manage/user-notes.php?action=edit+28809
http://master.php.net/manage/user-notes.php?action=delete+28809
http://master.php.net/manage/user-notes.php?action=reject+28809