期望与我的阵列的价值一致,这对这位控制者的看法至关重要。 我很想知道。 因此,就第一点点而言,我要对这一观点表示赞同。 然后,它会穿透其余部分。
这里是我的控制员守则:
function index()
{
$this->load->library( simplepie );
$feeds = array( mmafighting => http://www.mmafighting.com/rss/current ,
bbc => http://feeds.bbci.co.uk/news/world/us_and_canada/rss.xml ,
bloodyelbow => http://www.bloodyelbow.com/rss ,
ufc => http://www.ufc.com/rss/news ,
hackernews => http://news.ycombinator.com/rss ,
msnbc => http://www.msn.com/rss/news.aspx ,
msnbc2 => http://www.msn.com/rss/msnmoney.aspx ,
msnbc3 => http://www.msn.com/rss/msnshopping_top.aspx
);
foreach ($feeds as $site=>$url)
{
$data[ feed ][$site] = new SimplePie();
$data[ feed ][$site]->set_feed_url($url);
$data[ feed ][$site]->set_cache_location(APPPATH. cache );
$data[ feed ][$site]->set_cache_duration(300);
$data[ feed ][$site]->init();
$data[ feed ][$site]->handle_content_type();
}
$this->load->view( feedsview , $data);
}
这里我的看法是:
<?php
$feedCount = 0;
$rowCount = 0;
?>
<?php foreach ($feed as $site): ?>
<?php if ($site->data): ?>
<div class="feed">
<h2><?php // echo original array key here ?></h2>
<ul>
<?php $items = $site->get_items(0, 5); ?>
<?php foreach ($items as $item): ?>
<li><a href="<?php echo $item->get_link(); ?>"><?php echo $item->get_title(); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<?php $feedCount++; ?>
<?php if ($feedCount === 3) {
echo <div style="clear:both;"> </div> ;
$feedCount = 0;
$rowCount++;
if ($rowCount === 2) {
echo <div style="width:1000px; margin-bottom:20px;height:100px; border:1px solid #252525; float:left;">images</div> ;
}
} ?>
<?php endforeach; ?>