Reply to Re: [PHP] Limit iterations on a foreach loop?
Posted by Alex Hogan on 02/11/05 18:16
> I'm using an RSS feed that has WAY too much content, I only want the
> first 10. I'm outputting the array with a foreach loop: is there a way
> to limit it to only go through the first 10?
foreach($var as $newvar){
if($count <= 10){
// Do something here
}
else{
break;
}
}