VisualBuilder
  Home > Php > Tutorials > Programming Loops - PHP Tutorial
Tell a friend
Link to us
Total Members
      Members: 84661
     
Sitemap Forum Chat
Home
PHP Tutorial Home
1 . An Introduction to PHP
2 . Getting Started With Variables
3 . Comments in PHP
4 . Operators
5 . The Switch Statement
6 . Logical Operators
7 . Boolean Values
8 . Working with HTML Forms
9 . Programming Loops
10 . Arrays in PHP
11 . String Manipulation
12 . Create your own Functions
13 . Date and Time Functions in PHP
14 . Working With Files In PHP
 
 
PHP Home
PHP Members (3076)
PHP Member Articles ( 9 )
PHP Discussion (11)
PHP Q & A ( 13 )
- PHP Ask Question
- PHP Questions
- PHP Unanswered Questions
PHP Resources
PHP Source Code (463)
PHP Articles (118)
PHP Blogs (30)
PHP Jobs (0)
PHP Components (24)
PHP Books (3)
PHP Websites (29)
PHP News (17)
 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.Net Security,Internationalisation And Deployment
ASP.NET Tutorial
C# Tutorial
Web Development
Flex Tutorial
HTML Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Hibernate Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Spring Tutorial
Struts Tutorial

RESOURCES
Q & A (451 )
Source Code (3275 )
Articles (359 )
Books (372 )
Components (1596 )
News (892 )
Websites (1207 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Link To Us
Feedback
Tell a Friend
Partners
Advertise

Php Tutorial
 Programming Loops
  << Prev: Working with HTML Forms Next: Arrays in PHP >>

Programming Loops 



{
   echo " counter = " . $counter . "<BR>";
   $counter ;
}



?> 




5. Do ... While loops



This type is loop is almost identical to the while loop,except that the condition comes at the end.


 


do
statement
while (condition)


 


The difference is that your statement gets executed at least once. In a normal while loop,the condition could be met before your statement gets executed.


6. The break statement 



Break statement is used to stop the loop while loop is running to complete its round.


 


<?



$counter = 1;
while ($counter < 11)


{
   echo " counter = " . $counter . "<BR>";
   if($counter==7) break;


   $counter ;
}



?> 

1. For Loops


The loop goes round and round. Loops are used to redo the same action again and again until the limit you set.



 


for (start value; end value; update expression)


{}



 


 


<?
$counter = 0;
for($start=1; $start < 11; $start )


{
     $counter = $counter 1;
     echo $counter . "<BR>";
}


// $start equivalent to the $start = $start 1;



// $start-- equivalent to the $start = $start - 1;



?>



4. While Loops


The structure of a while loop is more simple than a for loop,because you’re only evaluating the one condition. The loop goes round and round while the condition is true. When the condition is false,the programme breaks out of the while loop.


 


while (condition)


{
    statement
}


 


<?



$counter = 1;
while ($counter < 11)



  << Prev: Working with HTML Forms Next: Arrays in PHP >>
Php Tutorial Home
Give feedback and win a prize.

 
   Printer Friendly
   Email to a friend
   Add to my Favourites    
  Download PDF version
   Report Bad Submissions
   Submit Feedback
 
  Delicious   Digg   Technorati   Blink   Furl   Reddit   Newsvine   Google Click each image to add
this page to each site.
 
 
Welcome Guest Signup
MEMBER'S PANEL
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!
 
SEARCH
 
 
 
ADVERTISEMENT
Partner List
Code Project
ASP Alliance
More
 
 
 
 

Home | Login | About Us | Contact Us | Privacy Policy | Advertising