I would like an inner (nested) while
loop to break when a condition is met, and continue an outer (parent) for
loop. I have created a simplified example:
<?php
$teams = array(
0 => array('points' => 4),
1 => array('points' => 1),
2 => array('points' => 3),
3 => array('points' => 8),
4 => array('points' => 2),
5 => array('points' => 6)
);
for($t = 1; $t < 6; $t++){
$break = 0;
echo "Team: " . $t . " ";
while($break == 0){
// The real case does complex calculations instead of the following line
echo "Points: " . $teams[$t]['points'] . "<br>";
if ($teams[$t]['points'] == 8){
$break = 1;
}
}
}
?>
Why does it fail? In my mind it should output:
Team: 1 Points: 1
Team: 2 Points: 3
Team: 3 Points: 8
Team: 4
Team: 5