note 23167 added to reserved.variables

From: Date: Thu, 11 Jul 2002 00:23:03 +0000
Subject: note 23167 added to reserved.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-32870@lists.php.net to get a copy of this message
// Replaces or removes elements from a querystring // changeArray should take the form array('p' => 'stock','tc' => null) etc // will return the same querystring, with any elements modded/removed/added function replaceOnQuerystring($changeArray) { $thisQuery = $_SERVER["QUERY_STRING"]; $queryArray = explode("&",$thisQuery); $counter = 1; foreach ($queryArray as $queryItem) { $querySegment = explode("=",$queryItem); if ($counter>1) { $tempString .= "&"; } if (isset($changeArray[$querySegment[0]])) { // Querystring key exists in changeArray - replace it (otherwise ignore it) // Remove element from changeArray for clearup afterwards $tempString .= $querySegment[0] . "=" . $changeArray[$querySegment[0]]; unset($changeArray[$querySegment[0]]); } else { // Querystring key doesn't exist in changeArray if (array_key_exists($querySegment[0],$changeArray)) { unset($changeArray[$querySegment[0]]); } else { $tempString .= $querySegment[0] . "=" . $querySegment[1]; } } $counter += 1; } // Add on end any leftovers in changeArray: while (list ($key, $val) = each ($changeArray)) { if ($val) { if ($counter>1) { $tempString .= "&"; } $tempString .= $key."=".$val; } } return $tempString; } -- http://www.php.net/manual/en/reserved.variables.php http://master.php.net/manage/user-notes.php?action=edit+23167 http://master.php.net/manage/user-notes.php?action=delete+23167 http://master.php.net/manage/user-notes.php?action=reject+23167

« previous php.notes (#32870) next »