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 for loop syntax:
for (initialization; condition check; increment/ decrement counter) {
code to be executed;
}
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:
foreach ($array as $value) {
code to be executed;
}
Example: PHP foreach loop example
"; } ?>
Result:
swift
alto
toyoto
I10
Reference