$xml = simplexml_load_file('rss.xml'); $say = 1; foreach($xml->channel->item as $item) { if($say<=5){ echo $item->title.' - '.$item->description.' - '.$item->image.'<br>'; $say++; }else{ //5e kadardı } }