Posted inTechnology / php / Programming

PHP Loop: For, ForEach, While, Do While [Example – for loop in php]

Today, We want to share with you for loop in php.In this post we will show you php for loop array length, hear for PHP Loop: For, ForEach, While, Do While [Example] we will give you demo and example for implement.In this post, we will learn about PHP Nested While Loops And Multiple Conditions with an example.

PHP While, Do-While, For and Foreach Loops

PHP for Loop

There are the following the Different Types of Loops in PHP

  • while
  • do…while
  • for
  • foreach

Example 1:



The Counter is: 0
The Counter is: 1
The Counter is: 2
The Counter is: 3
The Counter is: 4
The Counter is: 5
The Counter is: 6
The Counter is: 7
The Counter is: 8
The Counter is: 9
The Counter is: 10

Example 2:



The counter is: 0
The counter is: 10
The counter is: 20
The counter is: 30
The counter is: 40
The counter is: 50
The counter is: 60
The counter is: 70
The counter is: 80
The counter is: 90
The counter is: 100

PHP while Loop


PHP do…while Loop

while($counter <= 3);

PHP foreach Loop

 "pakainfo Welcome",
    "email" => "[email protected]",
    "age" => 25
// Loop through websiteInfo array
foreach($websiteInfo as $key => $value){
    echo $key . " : " . $value . "
"; } ?>

I hope you get an idea about for loop in php.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

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

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype