Page 1 of 1

Help on this would be greatly appreciated

Posted: Fri May 24, 2002 8:50 pm
by Pintonite
I am not to sure if this is possible but it would very useful if it could be done.

this is what I have for variables
$class1,$class2,$class3,...,$class10, and $count

I want to print out the information in these variables without having to specifically write code to do so for each one.

psuedo code:
count = 1;
while(count <= 10)
echo class"count"; // aka class1 or class2, whichever count is.

I want it to output the data in each of the variables. I have tried this with a couple of different syntaxes but none of them have worked. Is this even possible?

Thanks!
Mark

Posted: Fri May 24, 2002 8:56 pm
by lc
why not make them

Code: Select all

$class&#1111;1]
$class&#1111;2]
// and so forth

// then
foreach ($class as $key)&#123;
print "$key";
&#125;
or something

Posted: Fri May 24, 2002 9:11 pm
by volka
you may also use the eval()-function

Code: Select all

for ($i=1; $i!=11;$i++)
&#123;
 eval ("print("$class$i<br>");");
&#125;
but if this is a good idea.......