Reply to Re: How to access second element of the array $_REQUEST?

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация