Phploopcontinue-PHP source code

Source: Internet
Author: User
Ec (2); the number of times specified in the Code block executed by phploopcontinue, or the specified condition is true. -------------------------------------------------------------------------------- The number of times the script should be run when you know in advance. Syntax for (init; condition; increment) script ec (2); script

The number of times specified in the Code block executed by php loop continue, or the specified condition is true.


--------------------------------------------------------------------------------

For Loops
The loop is used when you know how many times the script should be run.

Syntax

For (Init; condition; increment)
{
Code to be executed;
}

Parameters:

Initialization: it is mainly used to set a counter (but it can be any code execution at the beginning of a loop)
Condition: evaluate each loop iteration. If the value is TRUE, the loop continues. If the value is FALSE, the loop ends.
Increment: it is mainly used to add a counter (but it can be that any code will be executed at the end of the loop)
Note: The preceding values can be null, or multiple expressions are used to separate each parameter (separated by commas ).

For example
The following example defines a loop starting with I = 1. The loop will continue to run because I only need to be less than or equal to 5. I will add 1 to run each loop:


For ($ I = 1; $ I <= 5; $ I ++)
{
Echo "The number is". $ I ."
";
}
?>


The number is 1
The number is 2
The number is 3
The number is 4
The number is 5

Instance 2

While (list ($ key, $ value) = each ($ arr )){
If (! ($ Key % 2) {// skip odd members
Continue;
}
Do_something_odd ($ value );
}

$ I = 0;
While ($ I ++ <5 ){
Echo "Outer
N ";
While (1 ){
Echo "Middle
N ";
While (1 ){
Echo "Inner
N ";
Continue 3;
}
Echo "This never gets output.
N ";
}
Echo "Neither does this.
N ";
}
?>

For ($ I = 0; $ I <5; ++ $ I ){
If ($ I = 2)
Continue
Print "$ in ";
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.