Re: Loop Through all Querystring Variables

From: Date: Wed, 24 Jan 2001 22:19:00 +0000
Subject: Re: Loop Through all Querystring Variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-36500@lists.php.net to get a copy of this message
At 3:07 PM -0700 1/24/01, Karl J. Stubsjoen wrote:
What is the simplest way to set up a procedure to loop through all passed querystring values and/or form values? I'm very new to PHP, and don't know how to set up loops at all.
reset($HTTP_GET_VARS); while (list($VariableName, $VariableValue) = each($HTTP_GET_VARS)) { echo "GET variable $VariableName was set to $VariableValue<br>\n"; } Of course, you would want to do your own processing in place of the echo. If you want to use POSTed or cookie variables, replace the _GET_ in the above snippet with _POST_ or _COOKIE_, respectively. The reset(), by the way, resets the array pointer to the beginning of the array. It's not always needed, but I tend to do it anyway. It IS necessary, however, ig you use the above snippet within an enclosing loop. - steve -- +--- "They've got a cherry pie there, that'll kill ya" ------------------+ | Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +-------------------------------------- FBI Special Agent Dale Cooper ---+

« previous php.general (#36500) next »