Help on this would be greatly appreciated

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
Pintonite
Forum Newbie
Posts: 17
Joined: Mon May 20, 2002 5:11 pm
Contact:

Help on this would be greatly appreciated

Post 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
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.......
Post Reply