|
Posted by Janwillem Borleffs on 08/06/05 13:58
talthen.z-serwera.o2@nospam.pl wrote:
> Hello,
> How to access second element of $_REQUEST?
>
> I tried echo $_REQUEST[2] and got nothing, but when i check
>
> p[rint_r($_REQUEST) then I see the array has surely more than 3
> elements.
$_REQUEST is not an indexed array, but associative. This means that values
can only be retrieved by keys.
Example:
The page is requested with a parameter foo with the value bar, as in:
page.php?foo=bar
If you want to print 'bar', you should do it like this:
print $_REQUEST['foo'];
But, you can get the values of the an associative array as an indexed array
through the array_values function:
$values = array_values($_REQUEST);
Afterwhich you can retrieve the values by their index:
print $value[1]; // 1 is the second index as 0 is always the first index
Please have a close look at the online manual starting at
http://www.php.net/manual/en/index.php to prevent asking basic questions
like this in the future.
JW
Navigation:
[Reply to this message]
|