How to use loop in Php ?

Question

How to use loop in Php ?

Re: How to use loop in Php ?

Let us take the example from the while loop lesson and see how it could be done in a for loop. The basic structure of
the for loop is as follows:
Pseudo PHP Code:
for ( initialize a counter; conditional statement; increment a counter){
do this code;
}
Notice how all the steps of the loop are taken care of in the for loop statement. Each step is separated by a semicolon:
initiliaze counter, conditional statement, and the counter increment. A semicolon is needed because these are separate
expressions. However, notice that a semicolon is not needed after the "increment counter" expression.
Here is the example of the brush prices done with a for loop .
PHP Code:
$brush_price = 5;

echo "
";
echo "

Quantity
";
echo "
Price

";
for ( $counter = 10; $counter <= 100; $counter += 10) {
echo "

";
echo $counter;
echo "
";
echo $brush_price * $counter;
echo "

";
}
echo "
"