Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i get the name of a form item from the _POST/_REQUEST array?

Status
Not open for further replies.

Robert1000

Programmer
Feb 25, 2004
4
0
0
AU
Two questions:

1) Is there a way to get the name of the form field when looping via foreach through the $_POST/$_REQUEST arrays?
ie if i have a field called txtUsername can i get this from $_POST? Simply to automatically create a variable for each form item.

something like:
foreach($_REQUEST as $blah)
{
print $blah->Name;
}

2) Also, why cant i use $_REQUEST[0], $_REQUEST[2] etc. If its a standard array this should work right? all that seems to work is something like

foreach($_REQUEST as $blah)
{
print $blah;
}

id have thought this would work

for ($i=0;$i<count($_REQUEST);$i++)
{
print $_REQUEST[$i];
}

of course it doesn't which is really strange. as count($_REQUEST) works fine

Cheers for any help
Rob
 
I answered your question here:
thread434-774020
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top