<?php
error_reporting(E_ALL);
// LOCATION OF THE FEED
$url = 'http://sports.espn.go.com/espn/rss/news';
//$url = 'http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/cricket/rss.xml';
// READ THE FEED
$xml = file_get_contents($url);
// CONVERT THE FEED TO AN OBJECT
$obj = SimpleXML_Load_String($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
// USE AN ITERATOR TO PRINT LINKS WITH THE ITEM TITLES
foreach ($obj->channel->item as $item)
{
$link = (string)$item->link;
$title = (string)$item->title;
$wrap_title= wordwrap($title, 62, "<br />");
$des = (string)$item->description;
$wrap_des = wordwrap($des, 79, "<br />");
if($url=="http://sports.espn.go.com/espn/rss/news")
{
$ini = strpos($wrap_des,"</a>");
$img_cut=substr($wrap_des,$ini);
}
else
{
$img_cut=$wrap_des;
}
echo "<div style='margin:0px auto;padding:0px;border:1px solid green;margin-bottom:20px;background:#CACACA;width:500px;'>";
echo "\n<a href=\"$link\">$wrap_title</a>";
echo "<br />";
echo "<div style='width:500px;'>$img_cut</div>";
echo "</div>";
}
?>
This comment has been removed by the author.
ReplyDeletePlease visit following link for learn more
ReplyDeleterelated PHP script(s)...
http://amitmondal.wordpress.com