Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Using cycling through input variables in PHP using foreach (See related posts)

This is a simple mechanism for cycling through all the inputs to a PHP script. If you're using $_GET (variables in the query string), $_POST (variables posted with a POST method on a form) or even $_SESSION (variables stored in the session) you can use this technique.

This snippet prints out all the variables in the $_GET variable (the query string) .

foreach ($_GET as $key => $value)
{
print "$key has a value of $value";
}


You need to create an account or log in to post comments to this site.


Click here to browse all 5141 code snippets

Related Posts