PHP - Break Statement

The keyword break ends execution of the current for, foreach, while, do while or switch structure. When the keyword break executed inside a loop the control automatically passes to the first statement outside the loop.the following example of break statement.

Example


<?php
	$a=1;
	while($a<=10)
	{
		echo $a;
		$a++;
	
		if($a==5)
		{
			break;
		}	
	}
?>									
							
Share Share on Facebook Share on Twitter Share on Google+ Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit