Minor syntax change (#22094)
This commit is contained in:
@ -4,7 +4,7 @@ title: Loop
|
||||
|
||||
# PHP Loop
|
||||
When you need to repeat same task for many times, you can use loop instead of keep adding same code over and over again.
|
||||
In PHP have following loop statements :
|
||||
In PHP you have the following loop statements :
|
||||
- for - loop through a block of code with specific number of times.
|
||||
- while - loop through a block of code if condition is true.
|
||||
- do...while - loop through a block of code one and continue loop if condition is true.
|
||||
@ -16,7 +16,8 @@ Using a `break` within the loop can stop the loop execution.
|
||||
Loop through a block of code with specific number of times.
|
||||
|
||||
## Syntax
|
||||
```
|
||||
```php
|
||||
|
||||
for (init counter; condition; counter increment or decrement)
|
||||
{
|
||||
// Code to be executed
|
||||
@ -49,7 +50,8 @@ for($index = 0; $index < 5; $index ++)
|
||||
Loop through a block of code if condition is true.
|
||||
|
||||
## Syntax
|
||||
```
|
||||
```php
|
||||
|
||||
while (condition)
|
||||
{
|
||||
// Code to be executed
|
||||
@ -90,7 +92,8 @@ while ($index >= 0)
|
||||
Loop through a block of code one and continue loop if condition is true.
|
||||
|
||||
## Syntax
|
||||
```
|
||||
```php
|
||||
|
||||
do
|
||||
{
|
||||
// Code to be executed
|
||||
@ -126,7 +129,7 @@ while ($index > 0);
|
||||
Loop through a block of code for each value within an array.
|
||||
|
||||
## Syntax
|
||||
```
|
||||
```php
|
||||
foreach ($array as $value)
|
||||
{
|
||||
// Code to be executed
|
||||
|
Reference in New Issue
Block a user