Thursday, February 3, 2011

Break while PHP looping

Assalamu'alaikum and selamat sejahtera

So,we already covered for,while and do..while loop.But as we learned that the PHP will still to loop until it reach the limit or the condition is does not true,ryte?.hOw about if we want to get out of the loop although PHP does not reach the limit or the condition still true.Okey,to do that,we must have some special code to done this task,luckily that special code is only one word that is break.Here is how the break is work:

$Interrupts = true;
$number = 1;

while ($number < =10) 
{
 

print("number = " + $number + "<BR>");
if ($Interrupts = = true) 

break;
 

$counter++;
}


Just try this code and run it.

N/NOTE:Explore it by yourself!see ya!

No comments:

Post a Comment