PHP For Loop

PHP For Loop

PHP For Loop

PHP For Loop, is one of the mostly used conditional loop .Basically the for Loop consist of an initial value, Conditional value and lastly incremental or decremented value.

  • For ( initial value;conditional ,;Increment / decrements)

Refer the code below for the For Loop Sample


<?php

for($n=1;$n<=10;$n++) {
     
   echo "The current iteration now is".$n.'<BR>';

     
    }


?>

Use For Loop to Print Out Array

<?php

$name=array(0000,1111,2222,3333);

$theLength = sizeof($name);

for($i=0;$i<$theLength;$i++){
	
	
	echo $name[$i].'<br>';

}
?>


Result

1111
2222
3333

Check out PHP do while Statement here

Check out PHP.net

Leave a Reply

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

5 × 1 =