-
-
//The current loop of php is 1, and the loop increases from the inside to the outside. The break defaults to 1, for example, jumping out of the second layer of loop - for ($i=0; $i<3;$i++){
- foreach (array(1,2,3) as $val){
- foreach (array(1,2,3) as $val){
- echo "1-level loop
";
- break 2; //Jump out of the 2nd level loop
- }
- echo "2nd level loop
";
- }
- echo "3rd level loop
";
- }
- //Result:
- //1 layer loop
- //3 layer loop
- //1 layer loop
- //3 layer loop
- //1 layer loop
- //3 layer loop
- ?>
-
Copy code
|