looping through numbered variables

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
chaza
Forum Newbie
Posts: 10
Joined: Fri Oct 10, 2003 11:28 am

looping through numbered variables

Post by chaza »

how can I output these variables in a for loop?


...not like this - but maybe not far off...

Code: Select all

<?php

$c0=1;
$c1=1;
$c2=0;
$c3=0;
$c4=1;
$c5=1;

for ($x=0;$x<6;$x++) {
	print $c{$x};
}

?>
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

you could just use an array ;)
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Or..
for ($x=0;$x<6;$x++) {
print ${'c'.$x};
}
Post Reply