PHP loops

Home » Tutorials » PHP » PHP loops
In this lesson we will consider basics of php again, namely loops in php. A lot of this you have already known from appropriate lesson in javascript. We will consider for, while, do…while loops
I remember, loops reduce repeating code. In real projects loops use in work with arrays.

Code lesson

<?php

$a = 10;

while($a>0) {
	echo $a . " ";
	$a--;
}

echo "<br>";

$b = 10;

do {
	echo $b. " ";
	$b--; 
} while ($b>=0);

echo "<br>";

for ($i=0; $i <10 ; $i++) { 
	echo $i . " ";
}

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

Pin It on Pinterest

Share This