From fe1b98d71a029b1685ed93f9bfc27ffab1d50dbd Mon Sep 17 00:00:00 2001 From: Alin Migea Date: Sun, 18 Nov 2018 06:31:26 +0200 Subject: [PATCH] Minor syntax change (#22094) --- guide/english/php/loop/index.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/guide/english/php/loop/index.md b/guide/english/php/loop/index.md index a38e330ed7..84a8e7630e 100644 --- a/guide/english/php/loop/index.md +++ b/guide/english/php/loop/index.md @@ -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