0

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.

Elitmiar
  • 35,072
  • 73
  • 180
  • 229
  • 1
    Please do not use the $_REQUEST array unless you are aware how it is put together and which security implications it poses. See http://stackoverflow.com/questions/2142497/whats-wrong-with-using-request – Gordon Feb 10 '10 at 13:03

3 Answers3

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
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