retrieving values form $_POST using loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ushassymon
Forum Newbie
Posts: 1
Joined: Sun Feb 15, 2009 7:10 am

retrieving values form $_POST using loop

Post by ushassymon »

Hi,

I am trying to access the variables through POST from an html post by using

$a=$_POST['a1'];

works fine.

Actually i have the vaiables from a1 to a28 getting posted from the html page. Is there any way I can use something like """ $a=$_POST['a'$i];""" ?? I want to read the $_POST array using a loop.
Eg.,
for ($i = 28; $I >=0; $i--)
{
$a=$_POST['here I want to substitute $i for a1, a2, a3...'];
}
Any help will be highly apreciated;

Many thanks in advance
Ushas Symon
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: retrieving values form $_POST using loop

Post by Bill H »

Code: Select all

 
for ($i = 28; $i >=0; $i--)
{
     $X = sprintf("a%d",$i);
     $a=$_POST[$X];
}
 
Next time use code tags and post code questions in the code forum, not in the forum that says.
"This forum is not for asking programming related questions."

(And don't mix caps and small i's in your loops.)
Post Reply