SlideShare a Scribd company logo
1 of 22
LOOPING STATEMENT IN PHP 1 www.YouStudy.IN
Looping statement Loops execute a block of code a specified number of times, or while a specified condition is true. In PHP, the following looping statements are used: The While Loop  The Do...While Loop  The For Loop  The Foreach Loop  Break and Continue Statements  2 www.YouStudy.IN
The while loop While structure is another type of loop statements, where the condition is checked at first, the iteration will not stop even if the value changes while executing statements. 3 www.YouStudy.IN
Syntax   while (condition) {  code to be executed;} 4 www.YouStudy.IN
Example  <?php$i=0;while ($i <= 10) { // Output values from 0 to 10   echo "The number is ".$i."<br />";   $i++;}?> 5 www.YouStudy.IN
The do while loop Do While statement is same as the while statement, the only difference is that it evaluates the expression at the end. 6 www.YouStudy.IN
Syntax  do {   code to be exected;}while (condition); 7 www.YouStudy.IN
Example  <?php $i = 0;do {   echo "The number is ".$i."<br/>";   $i++;} while ($i <= 10);?> 8 www.YouStudy.IN
The For Loop The for loop is used when you know in advance how many times the script should run. 9 www.YouStudy.IN
Syntax  for (initialization; condition; increment) {   code to be executed;} 10 www.YouStudy.IN
For loop cont.. he For statement takes three expressions inside its parentheses, separated by semi-colons. When the For loop executes, the following occurs: The initializing expression is executed. This expression usually initializes one or more loop counters, but the syntax allows an expression of any degree of complexity.  The condition expression is evaluated. If the value of condition is true, the loop statements execute. If the value of condition is false, the For loop terminates.  The update expression increment executes.  The statements execute, and control returns to step 2. 11 www.YouStudy.IN
Example  <?phpfor ($i=0; $i <= 10; $i++) {   echo "The number is ".$i."<br />";}?> 12 www.YouStudy.IN
The Foreach Loop For Each structure is a loop structure used for arrays 13 www.YouStudy.IN
Syntax  foreach (array as value){   code to be executed;}    foreach (array as key => value){   code to be executed;} 14 www.YouStudy.IN
Example  <?php$email = array('john.smith@example.com', 'alex@example.com');foreach ($email as $value) {   echo "Processing ".$value."<br />";}?> 15 www.YouStudy.IN
The break statement Break ends the execution of the for, for each, while, do-while or switch statement. 16 www.YouStudy.IN
Syntax  Break (Optional numeric argument)  17 www.YouStudy.IN
Example  <?php  $c = 0;  while (++$c)  {  switch ($c)  {  case 5:  echo "At 5;"; break 1;  case 10: echo "At 10; quitting"; break 2; default:  break;  } } ?>  18 www.YouStudy.IN
The continue statement "Continue" is used to skip the current loop iteration and continue with the next iteration of the loop. But "Break" is used to exit from the whole loop. 19 www.YouStudy.IN
Syntax  Continue (Optional numeric argument);  20 www.YouStudy.IN
Example  <?php for ($c = 0; $c <=10; ++$c)  { if ($c == 5)  { continue; } print "$c ";  }  ?>  21 www.YouStudy.IN
The End THANK U 22 www.YouStudy.IN

More Related Content

What's hot (20)

Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Loops in c
Loops in cLoops in c
Loops in c
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
The Loops
The LoopsThe Loops
The Loops
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Loops Basics
Loops BasicsLoops Basics
Loops Basics
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
Operators in java
Operators in javaOperators in java
Operators in java
 
If else statement in c++
If else statement in c++If else statement in c++
If else statement in c++
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Loop(for, while, do while) condition Presentation
Loop(for, while, do while) condition PresentationLoop(for, while, do while) condition Presentation
Loop(for, while, do while) condition Presentation
 
Exception handling in plsql
Exception handling in plsqlException handling in plsql
Exception handling in plsql
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
 
10. switch case
10. switch case10. switch case
10. switch case
 
Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and Operators
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
Conditional statement c++
Conditional statement c++Conditional statement c++
Conditional statement c++
 

Viewers also liked

Viewers also liked (20)

Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 
Loops in C Programming
Loops in C ProgrammingLoops in C Programming
Loops in C Programming
 
Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files
 
12 linux archiving tools
12 linux archiving tools12 linux archiving tools
12 linux archiving tools
 
Looping and Switchcase BDCR
Looping and Switchcase BDCRLooping and Switchcase BDCR
Looping and Switchcase BDCR
 
Fundamentals of programming finals.ajang
Fundamentals of programming finals.ajangFundamentals of programming finals.ajang
Fundamentals of programming finals.ajang
 
Looping in C
Looping in CLooping in C
Looping in C
 
Looping
LoopingLooping
Looping
 
Chapter 05 looping
Chapter 05   loopingChapter 05   looping
Chapter 05 looping
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement
 
C Language - Switch and For Loop
C Language - Switch and For LoopC Language - Switch and For Loop
C Language - Switch and For Loop
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structure
 
Loops in C
Loops in CLoops in C
Loops in C
 
Switch Case in C Programming
Switch Case in C ProgrammingSwitch Case in C Programming
Switch Case in C Programming
 
Do While and While Loop
Do While and While LoopDo While and While Loop
Do While and While Loop
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
Loops
LoopsLoops
Loops
 
C++ loop
C++ loop C++ loop
C++ loop
 
Loops c++
Loops c++Loops c++
Loops c++
 

Similar to Looping Statements in PHP: While, For, Foreach Explained

What Is Php
What Is PhpWhat Is Php
What Is PhpAVC
 
Php Operators N Controllers
Php Operators N ControllersPhp Operators N Controllers
Php Operators N Controllersmussawir20
 
03loop conditional statements
03loop conditional statements03loop conditional statements
03loop conditional statementsAbdul Samad
 
CPAP.com Introduction To Coding: Part 2
CPAP.com Introduction To Coding: Part 2CPAP.com Introduction To Coding: Part 2
CPAP.com Introduction To Coding: Part 2johnnygoodman
 
Computer programming
Computer programmingComputer programming
Computer programmingXhyna Delfin
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and loopingChaAstillas
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and loopingaprilyyy
 
PHP MATERIAL
PHP MATERIALPHP MATERIAL
PHP MATERIALzatax
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping newaprilyyy
 
Php Loop
Php LoopPhp Loop
Php Looplotlot
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.gerrell
 
Switch case and looping kim
Switch case and looping kimSwitch case and looping kim
Switch case and looping kimkimberly_Bm10203
 
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinarurumedina
 

Similar to Looping Statements in PHP: While, For, Foreach Explained (20)

What Is Php
What Is PhpWhat Is Php
What Is Php
 
Php Operators N Controllers
Php Operators N ControllersPhp Operators N Controllers
Php Operators N Controllers
 
03loop conditional statements
03loop conditional statements03loop conditional statements
03loop conditional statements
 
CPAP.com Introduction To Coding: Part 2
CPAP.com Introduction To Coding: Part 2CPAP.com Introduction To Coding: Part 2
CPAP.com Introduction To Coding: Part 2
 
Computer programming
Computer programmingComputer programming
Computer programming
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
PHP MATERIAL
PHP MATERIALPHP MATERIAL
PHP MATERIAL
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping new
 
Switch case and looping jam
Switch case and looping jamSwitch case and looping jam
Switch case and looping jam
 
Janakiram web
Janakiram webJanakiram web
Janakiram web
 
Final requirement
Final requirementFinal requirement
Final requirement
 
Php Loop
Php LoopPhp Loop
Php Loop
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.
 
Switch case and looping kim
Switch case and looping kimSwitch case and looping kim
Switch case and looping kim
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
My final requirement
My final requirementMy final requirement
My final requirement
 
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Lesson 6 php if...else...elseif statements
Lesson 6   php if...else...elseif statementsLesson 6   php if...else...elseif statements
Lesson 6 php if...else...elseif statements
 

More from ilakkiya

History object
History objectHistory object
History objectilakkiya
 
Twisted pair cable
Twisted pair cableTwisted pair cable
Twisted pair cableilakkiya
 
Network topology
Network topologyNetwork topology
Network topologyilakkiya
 
Looping statement in vb.net
Looping statement in vb.netLooping statement in vb.net
Looping statement in vb.netilakkiya
 
Conditional statement
Conditional statementConditional statement
Conditional statementilakkiya
 
Data types in php
Data types in phpData types in php
Data types in phpilakkiya
 
Array in php
Array in phpArray in php
Array in phpilakkiya
 
Decision statements in vb.net
Decision statements in vb.netDecision statements in vb.net
Decision statements in vb.netilakkiya
 
Addressing mode
Addressing modeAddressing mode
Addressing modeilakkiya
 

More from ilakkiya (10)

History object
History objectHistory object
History object
 
Twisted pair cable
Twisted pair cableTwisted pair cable
Twisted pair cable
 
Infrared
InfraredInfrared
Infrared
 
Network topology
Network topologyNetwork topology
Network topology
 
Looping statement in vb.net
Looping statement in vb.netLooping statement in vb.net
Looping statement in vb.net
 
Conditional statement
Conditional statementConditional statement
Conditional statement
 
Data types in php
Data types in phpData types in php
Data types in php
 
Array in php
Array in phpArray in php
Array in php
 
Decision statements in vb.net
Decision statements in vb.netDecision statements in vb.net
Decision statements in vb.net
 
Addressing mode
Addressing modeAddressing mode
Addressing mode
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 

Recently uploaded (20)

9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 

Looping Statements in PHP: While, For, Foreach Explained

  • 1. LOOPING STATEMENT IN PHP 1 www.YouStudy.IN
  • 2. Looping statement Loops execute a block of code a specified number of times, or while a specified condition is true. In PHP, the following looping statements are used: The While Loop The Do...While Loop The For Loop The Foreach Loop Break and Continue Statements 2 www.YouStudy.IN
  • 3. The while loop While structure is another type of loop statements, where the condition is checked at first, the iteration will not stop even if the value changes while executing statements. 3 www.YouStudy.IN
  • 4. Syntax while (condition) {  code to be executed;} 4 www.YouStudy.IN
  • 5. Example <?php$i=0;while ($i <= 10) { // Output values from 0 to 10   echo "The number is ".$i."<br />";   $i++;}?> 5 www.YouStudy.IN
  • 6. The do while loop Do While statement is same as the while statement, the only difference is that it evaluates the expression at the end. 6 www.YouStudy.IN
  • 7. Syntax do {   code to be exected;}while (condition); 7 www.YouStudy.IN
  • 8. Example <?php $i = 0;do {   echo "The number is ".$i."<br/>";   $i++;} while ($i <= 10);?> 8 www.YouStudy.IN
  • 9. The For Loop The for loop is used when you know in advance how many times the script should run. 9 www.YouStudy.IN
  • 10. Syntax for (initialization; condition; increment) {   code to be executed;} 10 www.YouStudy.IN
  • 11. For loop cont.. he For statement takes three expressions inside its parentheses, separated by semi-colons. When the For loop executes, the following occurs: The initializing expression is executed. This expression usually initializes one or more loop counters, but the syntax allows an expression of any degree of complexity. The condition expression is evaluated. If the value of condition is true, the loop statements execute. If the value of condition is false, the For loop terminates. The update expression increment executes. The statements execute, and control returns to step 2. 11 www.YouStudy.IN
  • 12. Example <?phpfor ($i=0; $i <= 10; $i++) {   echo "The number is ".$i."<br />";}?> 12 www.YouStudy.IN
  • 13. The Foreach Loop For Each structure is a loop structure used for arrays 13 www.YouStudy.IN
  • 14. Syntax foreach (array as value){   code to be executed;}    foreach (array as key => value){   code to be executed;} 14 www.YouStudy.IN
  • 15. Example <?php$email = array('john.smith@example.com', 'alex@example.com');foreach ($email as $value) {   echo "Processing ".$value."<br />";}?> 15 www.YouStudy.IN
  • 16. The break statement Break ends the execution of the for, for each, while, do-while or switch statement. 16 www.YouStudy.IN
  • 17. Syntax Break (Optional numeric argument) 17 www.YouStudy.IN
  • 18. Example <?php $c = 0; while (++$c) { switch ($c) { case 5: echo "At 5;"; break 1; case 10: echo "At 10; quitting"; break 2; default: break; } } ?> 18 www.YouStudy.IN
  • 19. The continue statement "Continue" is used to skip the current loop iteration and continue with the next iteration of the loop. But "Break" is used to exit from the whole loop. 19 www.YouStudy.IN
  • 20. Syntax Continue (Optional numeric argument); 20 www.YouStudy.IN
  • 21. Example <?php for ($c = 0; $c <=10; ++$c) { if ($c == 5) { continue; } print "$c "; } ?> 21 www.YouStudy.IN
  • 22. The End THANK U 22 www.YouStudy.IN