tags:

views:

42

answers:

2

Hi ,

I have a loop but I need to say that every time $i is printed the value of $i is a number so the start $i will be = 0 and at the end after 20 $i's it will be $i = 20

I hope some one can help

Thanks

+2  A: 

Use a for loop:

for ($i = 0; $i <= 20; $i++)
{
    echo $i . "\n";
}
John Conde
Hopefully you'll get credit for doing his homework!
Scott Saunders
This is wrong, after the end of this loop, `$i` will be 21.
Jacob Relkin
Is there a Stack Overflow policy for not answering questions when they are someone's homework?
littlegreen
Try it. It stops printing at 20. But it does loop 21 times which is okay since the question states it needs to stop at 20, not how many iterations it takes.
John Conde
+3  A: 

You want a for loop: http://php.net/manual/en/control-structures.for.php

Scott Saunders
+1 for not spoonfeeding the code
Gordon