Page 1 of 1

retrieving values form $_POST using loop

Posted: Sun Feb 15, 2009 7:17 am
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

Re: retrieving values form $_POST using loop

Posted: Sun Feb 15, 2009 8:44 am
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.)