Break in PHP

Google Advertisements

Prev Tutorial Next Tutorial

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

Prev Tutorial Next Tutorial

Google Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. If you want to post your article on our website/FB Group/FB Page please contact on hitesh.xc@gmail.com or 8076671483

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Path variable is set for providing path for all Java tools like java, javac, javap, javah, jar, appletviewer which are used in java programming. All these tools are available in bin folders so we set path upto bin folders.

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.

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

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

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483