Nesting Two for Loops : for loop « Statement « PHP






Nesting Two for Loops

 
<html>
<head><title>Nesting Two for Loops</title></head>
<body>
<div>
<?php
    print "<table>";
    for ( $y=1; $y<=12; $y++ ) {
      print "<tr>";
      for ( $x=1; $x<=12; $x++ ) {
        print "<td>";
        print ($x*$y);
        print "</td>";
      }
      print "</tr>";
    }
    print "</table>";
?>
</div>
</body>
</html>
  
  








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.Specifying a number after break, such as break 2, to break out of two loops or switch/case statements
21.Multiple expressions in for()
22.Printing a
23.Printing out all the web-safe color codes