I wanted to read RSS files: this is what I came up with....It works great, but how could I have done it easier?
$html=file_get_contents($url);
$html = explode("<title>", $html);//gets all of the title items into array
echo "<table>";
for($i = 3; $i<count($html);$i++)//want to start on first news story
{
echo "<tr><td>";
$data = str_replace("<title>", "", $html[$i]);//takes out title tag
$data = str_replace("</title>", ")", $data);//takes out title tag replaces with )
$data = str_replace("<description>", "", $data);//takes out description tag
$data = str_replace("</description>", ")", $data);//takes out description tag replaces with )
$data = str_replace("<link>", "", $data);//takes out link tag
$data = str_replace("</link>", ")", $data);//takes out link tag replaces with )
$data = str_replace("</item>", "", $data);//takes out item tag
$moredata = explode(")", $data);// gets array parts seperated by )
$title = $moredata[1];
$title = ltrim($title);
$description = $moredata[0];
$description = ltrim($description);
$link = $moredata[2];
$link = ltrim($link);
?>
<a href="<?=$link;?>" title="<?=$title;?>"><?=$description;?></a>
<?php
echo "</td></tr>";
}
echo "</table>";
}
RSS easier way?
Moderator: General Moderators
i use magpierss.sf.net