php - About displaying posts from two or more blogs -


i want display posts of 2 or more blogs in website using magpierss-0.72 fetching posts , code is

require_once('rss_fetch.inc'); $url = 'http://rajs-creativeguys.blogspot.com/feeds/posts/default?alt=rss' /*'http://raghuks.wordpress.com/feed/'*/; $rss = fetch_rss($url); foreach ($rss->items $i => $item ) { $title = strtoupper ($item['title']); $url = $item['link']; $date = substr($item['pubdate'],0,26); //code fetch text $desc = ''; $max = 30; $arr = explode(' ', strip_tags($item['description'])); $l = count($arr); if($l < $max) $max = $l; for($j=0;$j<$max;++$j) { $desc .= $arr[$j] . ' '; } $desc .= '.....'; echo "<div class=\"blog\"><a target=\"_blank\" href=$url><h1>$title</h1>$desc<br/><br/>dated : $date <br/><br/></a></div> "; if($i == 3) break; } 

here can specify 1 url of feeds , can fetch want display posts of 2 or more blogs please give me solution

thanks in advance

just use array , throw in foreach:

<?php require_once('rss_fetch.inc'); $urls = array( 'http://rajs-creativeguys.blogspot.com/feeds/posts/default?alt=rss', ' more urls ... ', ); foreach($urls $url) { /*'http://raghuks.wordpress.com/feed/'*/; $rss = fetch_rss($url); foreach ($rss->items $i => $item ) { $title = strtoupper ($item['title']); $url = $item['link']; $date = substr($item['pubdate'],0,26); //code fetch text $desc = ''; $max = 30; $arr = explode(' ', strip_tags($item['description'])); $l = count($arr); if($l < $max) $max = $l; for($j=0;$j<$max;++$j) { $desc .= $arr[$j] . ' '; } $desc .= '.....'; echo "<div class=\"blog\"><a target=\"_blank\" href=$url><h1>$title</h1>$desc<br/><br/>dated : $date <br/><br/></a></div> "; if($i == 3) break; } } 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -