Sunday, January 24, 2016

FOR LOOP IN PHP: Display Numbers Using For Loop

PHP loops execute a block of code a specified number of times. There are four (4) types of loops in PHP. The for loop, foreach loop, do while loop and the while loop. In this tutorial, we will be focusing on the while loop which I often used in creating iterations to save code and memory space.

PHP for loop is used to repeat execution of statement until a certain condition is true. First thing to do in the for loop is to initialize/to assign value to your variable, next is the conditional statement and last is the increment/decrement.

PHP Code for loop

echo $i;

Output for loop

That would be all. Thank you for visiting and hope this helps you. Feel free to leave a comment below for any questions. I got some other articles related to php in blog and even related to loops.

FOR LOOP IN PHP: Display Numbers Using For Loop

No comments:

Post a Comment