Hi I have this vars:
$chk1 ="a"; $chk2 ="b"; $chk3 ="c"; $chk4 ="d"; $chk5 ="e";
I want to create a loop and print the var like this:
for ($i=1;$i<6;$i++){ echo $chk.$i; }
But it is not working. How should I do it?
Assaf
create an array $chk[0] ... you will be able to create a loop more easy
hope that helps
try this in your loop:
&varvar = "chk".$1; echo $$varvar;
I haven't tested this. It is according to a book.
I think that the solution is more likely:
for ($i = 1; $i <= 5; $i++) { echo ${"chk" . $i}; }
Originally posted by laserlight I think that the solution is more likely: for ($i = 1; $i <= 5; $i++) { echo ${"chk" . $i}; } [/B]
Originally posted by laserlight I think that the solution is more likely:
[/B]
Thanks, It works!