Re: do while ?
| From: | Matthew Brealey | Date: | Thu, 23 Nov 2000 14:49:42 +0000 |
| Subject: | Re: do while ? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-26831@lists.php.net to get a copy of this message | ||
You wrote:
> I cant figure this out at all.Why doesnt this ever end?
> $i=1;
> do
> {
> echo $R1P;}
> while($i <16);
> $i++;
i++ never gets run - it's outside the loop - should be:
$i=1;
do {
$i++;
echo $R1P;
} while($i <16);
or, using non-silly syntax:
for ($i=1; $i<16; $i++) {
echo ${"R".$i."P"}; // To answer your question about how to get r1, r2, r3
}
-- Random fortune
Customer: "I've just installed Windows 98..."
Tech Support: "And?"
Customer: "The computer stopped working."
Tech Support: "You already said that..."