for

The for loop starts from an initial condition and iterates through the statements enclosed within the { code block } until the test is false.

 

The initial condition, test and iterator are separated by a semi-colon ;

 

for (initialiser ; test ; iterator) {

statements ;

statements ;

}

 

<?php

	for ($myVar ; $myVar < 5 ; $myVar++) {

		echo "\$myVar is currently $myVar<br>" ;

	}
?>

Leave a Reply