For loop in PHP

For loop is also for iteration.
syntax of for loop is

for (expr1; expr2; expr3)
   		statement;

The first expression (expr1) is evaluated (executed) once unconditionally at the beginning of the loop.
In the beginning of each iteration, expr2 is evaluated. If it evaluates to TRUE, the loop continues and the nested statement(s) are executed. If it evaluates to FALSE, the execution of the loop ends.
At the end of each iteration, expr3 is evaluated (executed).

An example of using for loop is given below.

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

OUTPUT: 0 1 2 3 4 5 6 7 8 9

Share This Post

Related Articles

16 Responses to “For loop in PHP”


  1. Here’s a comment. Great advice =) Thanks


  2. This is precisely what i was looking for. thanks for the insightful article and keep up the really good work!


  3. You made a number of fine points there. I did a search on the subject and found the majority of people will go along with with your blog.


  4. You made some nice points there. I did a search on the topic and found the majority of persons will consent with your blog.


  5. Please message me with any tips about how you made your blog look this awesome , I would be thankful!

  6. web site says:

    Resources just like the 1 you brought up here will probably be extremely valuable to me! I will publish a link to this web page on my personal website. Read my visitors will find that really useful.


  7. thanks amigo! great post!


  8. Straight to the point and written well, ty for the post


  9. Thanks for the great info! I would not have found this on my own!


  10. I just added your web page to my bookmarks. I really enjoy reading your posts. Tyvm!

  11. Dulce says:

    I totally agree that barack hussein obama sucks.


  12. How is it that just anyone can create a weblog and get as popular as this? Its not like youve said something incredibly impressive –more like youve painted a fairly picture around an issue that you know nothing about! I dont want to sound mean, right here. But do you really think that you can get away with adding some pretty pictures and not truly say anything?

  13. limo says:

    Thanks for sharing this helpful info!


  14. This is such a wonderful useful resource that you’re offering and you give it absent for free. I adore seeing internet websites that understand the worth of providing a quality resource for free. It?s the outdated what goes about comes about program.


  15. Resources such as the one you mentioned here will be incredibly useful to myself! I will publish a hyperlink to this page on my personal weblog. I am sure my site guests will locate that fairly useful.


  16. As a Newbie, I am forever searching online for articles that can help me. Thank you

Leave a Reply

*