Please advice how the following code works

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jintu
    FFR Player
    • Jul 2009
    • 15

    #1

    Please advice how the following code works

    Code:
    <html>
    <!-- test01.php -->
    <body>
    
       <?php 
          $x = 2;
          for ($i = 1; $i <= 6; $i++)
          {
              if ($i % 2 == 1)
              {
                 $x++;
              }
              print $i . 'x' . $i * $x . " ";
          }
    
       ?>
    
    </body>
    </html>
    *******
    Answer:

    1x3 2x6 3x12 4x16 5x25 6x30

    May I know, how did they arrive at the answer???

    Thanks...
Working...