Re: Simple newbie problem, please help!

From: Date: Fri, 17 Nov 2000 17:19:32 +0000
Subject: Re: Simple newbie problem, please help!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-25923@lists.php.net to get a copy of this message
On Fri, 17 Nov 2000, Static wrote: > > Hi everyone, I have a simple loop problem. > > Let's say I have 10 quiz questions, and for each one I have a variable, > i.e. q1answer, q2answer, etc... and in a for loop, I want to print them > out in a table. So I do something like this: > > for ($i = 1; $i <= 10; $i++) { > echo "<td width=\"25%\" bgcolor=\"#66CCFF\">"; > echo "<p align=\"center\"><font face=\"Arial\" > size=\"2\">VARIABLE > HERE</font></td>"; > > My problem is I don't know how to construct the VARIABLE HERE part. I > tried doing some kind of concatentation like q.$i.ans but that is > obviously wrong. Can someone please steer me in the right direction... > if an array is necessary, what needs to be done to get the 10 vars into > the array? > > Thanks so much in advance, > Omar > <?php for ($i=1; $i<=10; ++$i) { ?> <td width="25%" bgcolor="#66ccff"> <p align="center" style="font-family: Arial, helvetica, sans-serif; font-size: x-small"><?=${"q".$i."answer"}?></p> </td> <?php }; ?> -- Ignacio Vazquez-Abrams <ignacio@openservices.net>

« previous php.general (#25923) next »