您要寻找的可能是以下内容:
<ul id="news-ticker" style="float: left;height: 15px !important; margin-left: 2px; margin-top: 10px; overflow: hidden; position: relative;width: 500px;">
<?php
$rsslist = array(
"http://thehoopdoctors.com/online2/newfeed/",
"http://thepigskindoctors.com/newfeed/",
"http://thepuckdoctors.com/newfeed/",
"http://thecagedoctors.com/newfeed/",
"http://thedugoutdoctors.com/newfeed/",
"http://videogoneviral.com/newfeed/"
);
foreach ( $rsslist as $rssurl ): /* For every URL in the feed list */
$feed = fetch_feed($rrsurl);
foreach( $feed->get_items() as $item ): /* For every item */ ?>
<li class="news"><a style="color:white !important;" href="<?php echo $item->get_permalink();?>"><?php echo $item->get_title();?></a></li>
<?php break; /* Do only once, we only need one item */ ?>
<?php endforeach; ?>
<?php endforeach; ?>
</ul>
请注意,代码是如何分别获取每个URL的,而不是在多源模式下,并在
foreach $item
添加项目后立即循环。这将完成您的任务,从您的股票行情中的每个提要中获取一个项目。
此代码将执行相同的操作,但从每个提要中获取每个连续项:
<ul id="news-ticker" style="float: left;height: 15px !important; margin-left: 2px; margin-top: 10px; overflow: hidden; position: relative;width: 500px;">
<?php
$rsslist = array(
"http://thehoopdoctors.com/online2/newfeed/",
"http://thepigskindoctors.com/newfeed/",
"http://thepuckdoctors.com/newfeed/",
"http://thecagedoctors.com/newfeed/",
"http://thedugoutdoctors.com/newfeed/",
"http://videogoneviral.com/newfeed/"
);
$feedlist = array();
foreach ( $rsslist as $rssurl ) $feedlist []= fetch_feed( $rssurl ); /* store in feed array for later access */
$current_item_cycle = 0;
while ( sizeof($feedlist) ) { /* while feedlist is not empty */
foreach ( $feedlist as $index => $feed ) { /* cycle through each feed */
if (!$item = $feed->get_item($current_item_cycle++)) unset($feedlist[$index]); /* if feed has not more items unset */
else /* echo it out */ { ?>
<li class="news"><a style="color:white !important;" href="<?php echo $item->get_permalink();?>"><?php echo $item->get_title();?></a></li>
<?php }
}
} ?>
</ul>