SlideShare a Scribd company logo
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

Loops c++
Loops c++Loops c++
Loops c++
Shivani Singh
 
Php string function
Php string function Php string function
Php string function
Ravi Bhadauria
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in JavaJin Castor
 
Jumping statements
Jumping statementsJumping statements
Jumping statementsSuneel Dogra
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
Tiji Thomas
 
If-else and switch-case
If-else and switch-caseIf-else and switch-case
If-else and switch-case
Manash Kumar Mondal
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
Ravinder Kamboj
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
Sathish Narayanan
 
Inline function
Inline functionInline function
Inline functionTech_MX
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
Abhishek Choksi
 
Strings in C
Strings in CStrings in C
Strings in C
Kamal Acharya
 
Working with arrays in php
Working with arrays in phpWorking with arrays in php
Working with arrays in php
Kamal Acharya
 
Switch statements in Java
Switch statements  in JavaSwitch statements  in Java
Switch statements in JavaJin Castor
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
tanmaymodi4
 
Operators php
Operators phpOperators php
Operators php
Chandni Pm
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
WebStackAcademy
 

What's hot (20)

Loops c++
Loops c++Loops c++
Loops c++
 
Php string function
Php string function Php string function
Php string function
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
 
If-else and switch-case
If-else and switch-caseIf-else and switch-case
If-else and switch-case
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Inline function
Inline functionInline function
Inline function
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
Strings in C
Strings in CStrings in C
Strings in C
 
Working with arrays in php
Working with arrays in phpWorking with arrays in php
Working with arrays in php
 
Switch statements in Java
Switch statements  in JavaSwitch statements  in Java
Switch statements in Java
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Operators php
Operators phpOperators php
Operators php
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
Php basics
Php basicsPhp basics
Php basics
 

Viewers also liked

Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch casesMeoRamos
 
Loops in C Programming
Loops in C ProgrammingLoops in C Programming
Loops in C Programming
Himanshu Negi
 
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
Ahmed El-Arabawy
 
12 linux archiving tools
12 linux archiving tools12 linux archiving tools
12 linux archiving tools
Shay Cohen
 
Looping and Switchcase BDCR
Looping and Switchcase BDCRLooping and Switchcase BDCR
Looping and Switchcase BDCRberiver
 
Fundamentals of programming finals.ajang
Fundamentals of programming finals.ajangFundamentals of programming finals.ajang
Fundamentals of programming finals.ajangJaricka Angelyd Marquez
 
Looping in C
Looping in CLooping in C
Looping in C
Prabhu Govind
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
Mahantesh Devoor
 
Chapter 05 looping
Chapter 05   loopingChapter 05   looping
Chapter 05 looping
Dhani Ahmad
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement_jenica
 
C Language - Switch and For Loop
C Language - Switch and For LoopC Language - Switch and For Loop
C Language - Switch and For Loop
Sukrit Gupta
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structureJd Mercado
 
Loops in C
Loops in CLoops in C
Loops in C
Kamal Acharya
 
The Loops
The LoopsThe Loops
The Loops
Krishma Parekh
 
10. switch case
10. switch case10. switch case
10. switch case
Way2itech
 
Switch Case in C Programming
Switch Case in C ProgrammingSwitch Case in C Programming
Switch Case in C Programming
Sonya Akter Rupa
 
Do While and While Loop
Do While and While LoopDo While and While Loop
Do While and While Loop
Hock Leng PUAH
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loopsbsdeol28
 

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
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
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
 
The Loops
The LoopsThe Loops
The Loops
 
10. switch case
10. switch case10. switch case
10. switch case
 
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
 

Similar to Looping statement

What Is Php
What Is PhpWhat Is Php
What Is Php
AVC
 
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 statements
Abdul 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 MATERIAL
zatax
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping new
aprilyyy
 
Janakiram web
Janakiram webJanakiram web
Janakiram web
MARELLA CHINABABU
 
Php Loop
Php LoopPhp Loop
Php Looplotlot
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.gerrell
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
Saad Sheikh
 
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 statement (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.
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
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
 

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

BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 

Recently uploaded (20)

BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 

Looping statement

  • 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