break within a for loop
<?php
$primes = array(2,3,5,7,11,13);
for($count = 1; $count++; $count < 1000) {
$randomNumber = rand(1,50);
if (in_array($randomNumber,$primes)) {
break;
} else {
echo "<p>Non-prime number encountered: $randomNumber</p>";
}
}
?>
Related examples in the same category