PHP continue

PHP continue is a keyword use within looping structures.
continue skip the current loop iteration and then begin the next iteration depending on condition.
continue also accepts numeric argument like continue 1, continue 2 etc.
The default value is 1, thus skipping to the end of the current loop.
From PHP 5.4.0, continue 0; is no longer valid.
In previous versions it was interpreted the same as continue 1.

 

Example

Output:

Here it skip the value 3 due to continue.
 

PHP continue with arguments

Output:

Here when $j = 2, it skip ends execution of ‘if’ and inner ‘for’ loop.

Help others by sharing the content!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.