Break in PHP

Google Advertisements

Do While Loop in PHP Switch Case in PHP

Break Statement in PHP

PHP break statement breaks the execution of current for, while, do-while, switch and for-each loop. If you use break inside inner loop, it breaks the execution of inner loop only..

Syntax

jump statement;  
break;  

PHP Break inside loop

Example of break in php

<?php

for($i=1;$i<=10;$i++)
{  
echo "$i <br/>";  
if($i==5)
{  
break;  
}  
}  

?>

Output

1 2 3 4 5

PHP Break inside inner loop

Example break in php

<?php

for($i=1;$i<=3;$i++)
{
 for($j=1;$j<=3;$j++)
 {
  echo "$i   $j<br/>";
  if($i==2 && $j==2)
  {
   break;
  }
 }
}

?>

Output

1 1 1 2 1 3 2 1 2 2 3 1 3 2 3 3

PHP Break: inside switch statement

Example break in php

<?php

$num=5;    
switch($num){    
case 1:    
echo("Monday");    
break;    
case 2:    
echo("Tuesday");    
break;    
case 3:    
echo("Wednasday");    
break;
case 4:    
echo("Thrusday");    
break;
case 5:    
echo("Friday");    
break;
case 6:    
echo("Sateday");    
break;
case 7:    
echo("Sunday");    
break;

?>

Output

Friday

Do While Loop in PHP Switch Case in PHP

Google Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. For Advertisement contact on [email protected] or 8076671483

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: [email protected] or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar. Difference between path and classpath in Java

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: [email protected] or 8076671483 Try this Keyword C++ Programs