loops and break statement in php

In this example, we see how we can use loops and break statements in php

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>

</head>

<body>
<?php
$num=10;


while($num >= 0)
{
$num--;
  for($i=0; $i<10; $i++)
  {
    echo "loop i = " . $i . " <br>" ;
   if($num == 5)
   {
     echo "<br>Loop is break<br>";
    break;	 
    }
  }

echo "num=" . $num . " i=" . $i .  "<br>";	
}	


?>
</body>
</html>

 

Add a Comment

Your email address will not be published. Required fields are marked *