Loading...
Поиск скриптов | Лимит на вывод
Как сделать лимит на вывод новостей на PHP?
Для начала, не плохо было бы узнать в каком виде выводятся данные...
Simptom333 , Ах да... Так и знал что, что то забыл. Вот код:
php
   <?php $rss=simplexml_load_file('https://m.lenta.ru/rss/news'); header("Content-Type: text/html; charset=utf-8");  foreach ( $rss->channel->item as $item ) { $image = $item->enclosure; echo '<img src="'.$image['url'].'" width="'.$image['width'].'" height="'.$image['height'].'" alt="" class="responsive" />'; echo '<div style="padding:5px;">'; echo '<a style="font-weight:700;font-size:16px;" href="'.$item->link.'">'.$item->title.'</a>'; echo '<div style="font-size:15px;">'.$item->description.'</div>'; echo '</div>'; echo '<br/><br/>'; } ?>   
540447140 ,
php
   $rss=simplexml_load_file('https://m.lenta.ru/rss/news'); header("Content-Type: text/html; charset=utf-8"); $limit = 0; foreach ( $rss->channel->item as $item ) { if ($limit == 10) break; $image = $item->enclosure; echo '<img src="'.$image['url'].'" width="'.$image['width'].'" height="'.$image['height'].'" alt="" class="responsive" />'; echo '<div style="padding:5px;">'; echo '<a style="font-weight:700;font-size:16px;" href="'.$item->link.'">'.$item->title.'</a>'; echo '<div style="font-size:15px;">'.$item->description.'</div>'; echo '</div>'; echo '<br/><br/>'; $limit++; }   
540447140 ,
php
   array_slice($rss->channel->item,0,10)   
Онлайн: 2
Время:
Gen. 0.097
(c) Bym.Guru 2010-2026