Page 1 of 1

concatenation to produce series of variables

Posted: Wed Aug 24, 2005 7:02 pm
by bwv2
I want to produce a series of variables called "var1, var2, ..., var15" by using concatenation. Here is what I have so far:

Code: Select all

for($i=0; $i<=15; $i++){
$var.$i=$_POST["value_".$i.""];
}
The result is confusing. I may be doing this correctly and my problem could be elsewhere, but as of now I think this may be the issue. Anyone see anything wrong with my method of joining the two variables on line 2 of my code? Thanks.

Posted: Wed Aug 24, 2005 7:31 pm
by nielsene

Code: Select all

for ($i=1;$i<=15;$i++) {
  $varName = "var".$i;
  $$varName=$_POST["value_$i"];
}