PHP Continue

0
4χλμ.

The continue statement can be used to jump out of the current iteration of a loop, and continue with the next.


Continue in For Loops

The continue statement stops the current iteration in the for loop and continue with the next.

ExampleGet your own PHP Server

Move to next iteration if $x = 4:

for ($x = 0; $x < 10; $x++) {
  if ($x == 4) {
    continue;
  }
  echo "The number is: $x <br>";
}
Try it Yourself »

Continue in While Loop

The continue statement stops the current iteration in the while loop and continue with the next.

Continue Example

Move to next iteration if $x = 4:

$x = 0;

while($x < 10) {
  if ($x == 4) {
    continue;
  }
  echo "The number is: $x <br>";
  $x++;
}
Try it Yourself »


Continue in Do While Loop

The continue statement stops the current iteration in the do...while loop and continue with the next.

Example

Stop, and jump to the next iteration if $i is 3:

$i = 0;

do {
  $i++;
  if ($i == 3) continue;
  echo $i;
} while ($i < 6);
Try it Yourself »

Continue in For Each Loop

The continue statement stops the current iteration in the foreach loop and continue with the next.

Example

Stop, and jump to the next iteration if $x is "blue":

$colors = array("red", "green", "blue", "yellow");

foreach ($colors as $x) {
  if ($x == "blue") continue;
  echo "$x <br>";
}
Try it Yourself »
Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
άλλο
PHP Multidimensional Arrays
In the previous pages, we have described arrays that are a single list of key/value pairs....
από PHP Tutorial 2024-05-17 08:07:20 0 7χλμ.
άλλο
PHP Math
PHP has a set of math functions that allows you to perform mathematical tasks on numbers. PHP...
από PHP Tutorial 2024-05-17 07:39:09 0 6χλμ.
άλλο
PHP - Escape Characters
Escape Character To insert characters that are illegal in a string, use an escape character. An...
από PHP Tutorial 2024-05-17 07:32:36 0 11χλμ.
άλλο
PHP if Statements
Conditional statements are used to perform different actions based on different conditions....
από PHP Tutorial 2024-05-17 07:45:23 0 4χλμ.
άλλο
PHP Operators
PHP Operators Operators are used to perform operations on variables and values. PHP divides the...
από PHP Tutorial 2024-05-17 07:41:39 0 9χλμ.
Sociallez https://sociallez.com