0
我使用simplexml_load_file
从wordpress博客获取rss订阅源。这里是我的代码simplexml_load_file从WP订阅源重复生成相同的帖子
$rssfile = simplexml_load_file("http://blog.sufuraamathi.com/?feed=rss2");
$items = $rssfile->channel->item ;
foreach($items as $item) {
$article = array();
$article['title'] = $item->title;
$article['link'] = $item->link;
$article['category'] = $item->category;
}
foreach($items as $item) { ?>
<?php if($article['category']=="Uncategorized") { ?>
<div><?php echo $article['title'];?></div>
<?php
} } ;
?>
的问题:它重复输出同一职位x次,其中x是职位的总数。目前,Uncategorized
类别中只有两个帖子,其他类别中有三个帖子。但代码回声如下:
<div>Hello world!</div>
<div>Hello world!</div>
<div>Hello world!</div>
<div>Hello world!</div>
<div>Hello world!</div>