Re: Loop Through all Querystring Variables

From: Date: Wed, 24 Jan 2001 22:20:32 +0000
Subject: Re: Loop Through all Querystring Variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-36501@lists.php.net to get a copy of this message
Assuming you are using GET (since you have a QUERY_STRING in url) : foreach ($HTTP_GET_VARS as $key => $value) { print "<br>$key is $value \n"; } For form you can use POST and loop through HTTP_POST_VARS too. These are predefined variables : http://www.php.net/manual/en/language.variables.predefined.php That should get you started :-) Foreach is php4+ specific, manual has examples using a while loop too, see : http://www.php.net/manual/en/control-structures.foreach.php Note that if you're passing arrays through your forms (which everyone should do!!!) then adjust accordingly. A quick method to just view (dump) the data is using : print_r($SOME_SPIFFY_VARIABLE_ARRAY); -OR- var_dump($A_HUGE_ARRAY_TO_DISPLAY); Those are two very beautiful functions to play with, for debugging and such. Viewing $HTTP_GET_VARS through them will quickly show you what is passing. I recommend surrounding those "debugging functions" with <pre> as it creates a much prettier output to browser. But I digress. Oh, phpinfo() will tell you which predefined variables you get to play with as each server is setup differently. Regards, Philip Olson On Wed, 24 Jan 2001, 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. > > Thanks! Karl > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#36501) next »