PHP for and foreach loop statement

It is used when one knows how many time one need to run the particular loop. It is also of two types:

1. PHP for loop statement

Loop back again and again through specified time duration.

Read More

PHP while loop

PHP do while loop

PHP for loop syntax:

Example: PHP for loop example

Result:

The number is: 0
The number is: 1
The number is: 2
The number is: 3

2. PHP foreach loop statement

For each elements in the array it give result.
It is used to iterate all the elements over array.

PHP foreach loop syntax:

Example: PHP foreach loop example

Result:
swift
alto
toyoto
I10

Reference

For Loop