Specifying a number after break, such as break 2, to break out of two loops or switch/case statements : for loop « Statement « PHP






Specifying a number after break, such as break 2, to break out of two loops or switch/case statements

 
<?
    for ($i = 1; $i < 3; $i = $i + 1) {
            for ($j = 1; $j < 3; $j = $j + 1) {
                    for ($k = 1; $k < 3; $k = $k + 1) {
                            print "I: $i, J: $j, K: $k\n";
                            break 2;
                    }
            }
    }
?>
  
  








Related examples in the same category

1.For statement without second condition
2.For statement without all three statements
3.For loop: Counting Backwards
4.For loop: Counting By Fives
5.Use for loop to output HTML table
6.For loop format
7.If statement inside a for loop
8.Nesting Two for Loops
9.A for Loop That Divides 4000 by Ten Incremental Numbers
10.Using the for Statement
11.A division table
12.A for Loop That Divides 4000 by Ten Incremental Numbers
13.A for loop in PHP
14.Alternating table row colors with for()
15.Loops Within Loops
16.Iterating through a multidimensional array with for()
17.Iterating through a numeric array with for()
18.Loop goes from 0 to 100 in steps of 0.1
19.Fahrenheit and Celsius table by for loop
20.Multiple expressions in for()
21.Nesting Two for Loops
22.Printing a
23.Printing out all the web-safe color codes