This class has 3 functions that might help you with RSS
Class
PHP Code:
<?php
class rss{
var $items = array();
function add($a, $b){ // Adds a rss item
$this->items = array_merge($this->items, array(array("title" => $a, "link" => $b)));
}
function write($a){ // Prints out the all items, in RSS style, defined by add()
$out = '<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
<title>'.$a.'</title>';
foreach($this->items as $items){
$out .= "
<item>
<title>".$items['title']."</title>
<link>".$items['link']."</link>
</item>";
}
$out .= '
</channel>
</rss>';
return $out;
}
function read($a, $b){ //Get the title and link out of RSS feed
$cr = 0;
$p = array();
$a = file_get_contents($a);
while($cr != $b){
$i = strings::get($a, "<item>", "</item>");
$l = array(array("title" => strings::get($i, "<title>", "</title>"), "link" => strings::get($i, "<link>", "</link>")));
$p = array_merge($p, $l);
$k = strings::get($a, "<item>", "</item>");
$a = str_replace("<item>".$k."</item>", "", $a);
++$cr;
}
return $p;
}
}
?>
Example
PHP Code:
<?php
/*
Class
*/
header("Content-Type: application/xml");
$rss = new rss;
$rss->add("tizag", "http://www.tizag.com/");
$rss->add("digg", "http://www.digg.com/");
$rss->write("sample");
?>