While loop inside while loop

Discussion in 'PHP' started by karthickr, Apr 10, 2011.

  1. karthickr

    karthickr New Member

    Joined:
    Apr 10, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi, I am new to PHP. Can anyone tell me how to use while loop inside while loop?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Code:
    While (SomeCondition)
    {
        While (SomeCondition)
        {
    
        }
    }
     
  3. underground_devil

    underground_devil New Member

    Joined:
    Jan 24, 2011
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    PHP developer ,trainer
    Location:
    Punjab
    example
    PHP:
    <?php
    $i
    =1;
    while(
    $i<5)
          {
              
    $j=1
               
    while($j<$i)
               {
                echo 
    $j." ";
                 
    $j++;
                }
          echo 
    "<br>";
          }
    out put would be
    1 2 3 4 5
    1 2 3 4
    1 2 3
    1 2
    1
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice