Possible Duplicate:
How would I stop this foreach loop after 3 iterations?
I have a for loop in PHP.
When a condition is met, I would like it to stop runnning, right now it still continues all the way to 10000 $i values. I want it to totally stop after it finds 6 and continue with the rest of my code.
I have:
$bigarray=...
$countrec=0;
for ($i=1;$i<10000;$i++){
if($countrec<6){
if(array_search($i,$bigarray)!=-1){
echo "Test! $i<br>";
$countrec++;
}
}
}
How can I stop it early?