Page 1 of 1

looping through numbered variables

Posted: Sun Apr 04, 2004 10:27 am
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};
}

?>

Posted: Sun Apr 04, 2004 11:25 am
by Deemo
you could just use an array ;)

Posted: Sun Apr 04, 2004 8:17 pm
by markl999
Or..
for ($x=0;$x<6;$x++) {
print ${'c'.$x};
}