PHP for Loop Use example Introduction, PHP instance
The For loop is used in cases where you know in advance how many times the script needs to run.
Grammar
for (initial value; condition; increment) {code to execute;}
Parameters:
- Initial value : The primary is to initialize a variable value that sets a counter (but can be any code that is executed once at the beginning of the loop).
- condition : The throttling condition of the loop execution. If true, the loop continues. If FALSE, the loop ends.
- increment : Mainly used for incrementing the counter (but can be any code executed at the end of the loop).
Note: The above initial and increment parameters can be empty, or there are multiple expressions (separated by commas).
The following example defines a loop with an initial value of I=1. As long as the variable i is less than or equal to 5, the loop continues to run. Each time the loop is run, the variable i increments by 1:
";}? >
Output:
The number is 1The number are 2The number is 3The number are 4The number is 5
Original address: http://www.manongjc.com/php/php_while.html
Related reading:
PHP strtok () Usage-php strtok () Function Example explained
The difference between PHP string segmentation function Strtok () and explode ()
PHP strtr () string substitution function usage Analysis
PHP substr () intercepts substrings of a specified length from the specified position in the string
http://www.bkjia.com/PHPjc/1130979.html www.bkjia.com true http://www.bkjia.com/PHPjc/1130979.html techarticle the PHP for loop uses an example, and the PHP instance for loop is used in cases where you know in advance how many times the script needs to run. Syntax for (initial value; condition; increment) {code to execute;} parameter ...