Septanet Forum  

Go Back   Septanet Forum > Computers, Software, Harware, Information Technology > PHP Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-08-2011, 03:32 PM   #1
Senior Member
 
sharma.s.prakash's Avatar
 
Join Date: Aug 2011
Posts: 110
Default While loop in php

while programming as kaman writes these are the basic and after that you must have the knowledge of the control structure how to use and where to use
like if condtion
for loop
while loop
do while
switch case
and another loop in php is foreach
loops have the major roll in controling the flow of program
while loop
replace \n with <br> if usingbrowser for output

PHP Code:
$num=1;
while(
$num<=5){
    
$i=1;
    while(
$i<=$num){
        echo 
$i;
        
$i++;
    }
    echo 
"\n";
    
$num++;


out put is
1
12
123
1234
12345
just do nothing revers the loop

PHP Code:
$num=5;
while(
$num>=1){
    
$i=1;
    while(
$i<=$num){
        echo 
$i;
        
$i++;
    }
    echo 
"\n";
    
$num--;

output
12345
1234
123
12
1
sharma.s.prakash is offline  
Digg this Post!Bookmark Post in Technorati
Reply With Quote
Old 05-08-2011, 04:07 PM   #2
Senior Member
 
kaman's Avatar
 
Join Date: Aug 2011
Posts: 111
Thumbs up

Like It...!
kaman is offline  
Digg this Post!Bookmark Post in Technorati
Reply With Quote
Old 25-08-2011, 12:16 PM   #3
Senior Member
 
harry's Avatar
 
Join Date: Aug 2011
Posts: 103
Default

thanks very useful
harry is offline  
Digg this Post!Bookmark Post in Technorati
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 12:53 PM.


Content Relevant URLs by vBSEO 3.5.0 RC2