I have a problem with breaking from loops. I have code like this:
<?php $return = array(...); while(true) { foreach($return AS $row) { if($row['timer'] > 15) break; } sleep(2); }
And I need to break while (true)
You can specify how many loops you want to split this way:
break 2;
So in your case:
while(true) { foreach($return AS $row) { if($row['timer'] > 15){ break 2; } } sleep(2); }
$breakfromloop = false; while(!$breakfromloop) { foreach($return AS $row) { if($row['timer'] > 15) { $breakfromloop = true; } } sleep(2); }
You can try something like this:
$return = array(...); $break = false; while(true) { foreach($return AS $row) { if($row['timer'] > 15){ $break = true; break; } } if(true === $break) break; sleep(2); }