5. Loops in PHP

Loops execute a block of code a specified number of times, or while a specified condition is true.

Loops - While Statement :   
  • The while loop executes a block of code while a condition is true.
  • while (condition)
    {
    code to be executed;
    }
[ Code ] : 
http://pastebin.com/EX7L8f4J

For More loops Click On READ MORE

Loops - Do-While Statement :
  •  The do...while statement will always execute the block of code once, it will then check the condition, and repeat the loop while the condition
  •   is true.
  • do
     {
     code to be executed;
     }while (condition); 
http://pastebin.com/rQy7xwtG
Loops - For Statement  :
  • The for loop is used when you know in advance how many times the script should run.
  • for (init; condition; increment)
     {
     code to be executed;
     }
http://pastebin.com/r7zMVwMM
 Loops - Foreach Statement :
  • The foreach loop is used to loop through arrays.
  • foreach ($array as $value)
     {
     code to be executed;
     }
http://pastebin.com/AT1Ft4kA

0 comments:

Post a Comment