If statement inside a for loop : for loop « Statement « PHP






If statement inside a for loop


<?php
  $a = -3;
  for (; $a <= 20; $a++){
      if ($a == 0){
          break;
      }    
      $divide = 40/$a;
      echo "The result of dividing 40 by $a is $divide", "<BR>";
  }
  ?>
           
       








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.Nesting Two for Loops
8.A for Loop That Divides 4000 by Ten Incremental Numbers
9.Using the for Statement
10.A division table
11.A for Loop That Divides 4000 by Ten Incremental Numbers
12.A for loop in PHP
13.Alternating table row colors with for()
14.Loops Within Loops
15.Iterating through a multidimensional array with for()
16.Iterating through a numeric array with for()
17.Loop goes from 0 to 100 in steps of 0.1
18.Fahrenheit and Celsius table by for loop
19.Specifying a number after break, such as break 2, to break out of two loops or switch/case statements
20.Multiple expressions in for()
21.Nesting Two for Loops
22.Printing a
23.Printing out all the web-safe color codes