Hey.
I'm trying to get an array of all GET-variables passed to a PHP document.
Is this possible?
Thanks. :)
Hey.
I'm trying to get an array of all GET-variables passed to a PHP document.
Is this possible?
Thanks. :)
It's already there by default:
print_r($_GET); // for all GET variables
print_r($_POST); // for all POST variables
There is a $_GET
super global array to get all variables from query string.
// print all contents of $_GET array
print_r($_GET);
// print specific variable
echo $_GET['key_here'];
You can also use foreach
loop to go through all of them like this:
foreach($_GET as $key => $value)
{
echo 'Key = ' . $key . '<br />';
echo 'Value= ' . $value;
}
The $_REQUEST variable is:
An associative array that by default contains the contents of $_GET, $_POST and $_COOKIE.
http://www.php.net/manual/en/reserved.variables.request.php
That could help