Break Control Structure:
Break is a special kind of control structure which helps us to break any loop or sequence, like if we want to break the flow of any loop (for, while etc) then we can use break statement, generally we need if control structure to implement .
If you want to break multiple control structure then we need to provide numeric argument along with break statement, example is given below:
Example:
<?php
for
($a=1;$a<10;$a++){
if($a==5) break; elseecho
"$a\t";}
?>
Output:
1 2 3 4
Example:
<?php
$arr
=array(1,2,3,4,5);foreach
($arr as $val):if
($val==4)break;echo
$val."<br/>";endforeach
;?>
Output:
1
2
3
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.