I need to obtain the identifier, name of Global variables. Eg. If I have $_REQUEST['email'] I need to obtain the word email within the $_REQUEST variable.
Asked
Active
Viewed 156 times
3 Answers
2
It's not very clear from this what you want. If you need a list of available keys in $_REQUEST
, you can use array_keys($_REQUEST)
.

Wim
- 11,091
- 41
- 58
0
This will print every key with its value:
foreach($_REQUEST as $key => $value) {
print "{$key} => {$value}<br />";
}

Davide Gualano
- 12,813
- 9
- 44
- 65
-
2Or you could just use `print_r($_REQUEST);`, or `var_dump($_REQUEST);`. – Mathias Bynens Feb 10 '10 at 13:06
0
You could also use
$k = array_keys($_REQUEST);
foreach($k as $v){
writelog( "out.txt", $v); // The key name
writelog( "out.txt", $_REQUEST[$v]); // the key value for the name
}
writelog is a simple log file function I use to help me debug and not essential to the answer.
function writelog( $logfilename, $description)
{
date_default_timezone_set('Australia/Melbourne');
if (isset($_SESSION['loginID']))
file_put_contents("out.txt", date("Y-m-d H:i:s ") . $description . " " . $_SESSION['loginID'] . "\n", FILE_APPEND );
else
file_put_contents("out.txt", date("Y-m-d H:i:s ") . $description . " NLO\n", FILE_APPEND );
}

hatchnet
- 111
- 1
- 5