php exit second foreach code example
Example 1: php exit foreach
$arr = array('one', 'two', 'three', 'four', 'stop', 'five');
foreach ($arr as $val) {
if ($val == 'stop') {
break;
}
echo "$val<br />\n";
}
$i = 0;
while (++$i) {
switch ($i) {
case 5:
echo "At 5<br />\n";
break 1;
case 10:
echo "At 10; quitting<br />\n";
break 2;
default:
break;
}
}
?>
Example 2: teruglopende for loop php
<?php
$weekday = array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday", "Sunday");
for($i = 6; $i >= 0; $i = $i -1){
print ( "$weekday[$i]<br>" );
}
?>