for and foreach Loop in PHP:

For loop :

for loop in PHP is used when you already know that for how many times you want to execute the code.


In above syntax you can see that we have passed three parameters in for loop.

  • Initialization: here we set the start value of counter
  • Condition: checking the condition if it is true or false
  • Increment: finally increase the loop counter


 foreach loop:

The foreach loop in PHP is use to perform looping on Arrays means foreach loop is works only for array.


In foreach loop the value of current array element is assigned to $value and it will continue up to last array.



4 responses to “for and foreach Loop in PHP”

  1. Vashti Kilness says:

    Amazing! This blog looks exactly like my old one! It’s on a totally different subject but it has pretty much the same page layout and design. Outstanding choice of colors!

  2. Deana Prendergast says:

    I would like to thank you for the efforts you’ve put in penning this website. I’m hoping to check out the same high-grade blog posts from you later on as well. In fact, your creative writing abilities has motivated me to get my own, personal website now 😉

  3. Darwin Rattley says:

    You made some first rate points there. I looked on the web for the problem and located most individuals will go together with together with your website.

  4. Thanks for finally talking about > Importance of for and foreach loop | < Loved it!

Leave a Reply

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