note 33278 added to reserved.variables
| From: | prophet at bestweb dot net | Date: | Fri, 20 Jun 2003 17:33:49 +0000 |
| Subject: | note 33278 added to reserved.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-50763@lists.php.net to get a copy of this message | ||
Decided to rewrite the previous "replaceOnQuerystring" function listed on this page,
because it wasn't working for me :
function replaceOnQuerystring($changeArray)
{
$thisQuery = $_SERVER["QUERY_STRING"];
$queryArray = explode("&",$thisQuery);
$counter = 0;
foreach ($queryArray as $queryItem) // changes / modifications to existing.
{
if($counter != 0) // Make sure its not the 1st time around.
{
$newQuery .= '&'; // append a & to the query string, for the next var.
}
$querySegment = explode("=",$queryItem); // get the name and value into an array.
$varName = $querySegment[0]; // variable name
$varValue = $querySegment[1]; // variable value
if(isset($changeArray[$varName])) // is the var name listed in the changes?
{ // yes.
$newQuery .= $varName . '=' . $changeArray[$varName]; // add the changes to the new
query string.
unset($changeArray[$varName]); // remove from change array, so we don't repeat.
}
else
{ // no.
$newQuery .= $varName . '=' . $varValue; // leave it be, and add it to the new query.
}
$counter++; // up the counter so it knows to add a &.
}
foreach($changeArray as $changeItem => $changeValue) // loop though the changearray to clean up
any vars being added.
{
if($counter != 0)
{
$newQuery .= '&';
}
$newQuery .= $changeItem . '=' . $changeValue; // add it in.
unset($changeArray[$changeItem]); // unset it.
$counter++;
}
//return $_SERVER['PHP_SELF'] . '?' . $newQuery;
return $newQuery;
}
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33278
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33278&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33278&report=yes