I have a script which parses xml feeds, the url's to the feeds that are being parsed are in a table on my database.
Below is the query for storing the url's in an array
$getUrls = "SELECT * FROM sscape_blogroll";
$result = mysql_query($getUrls);
$urls = array();
while($row = mysql_fetch_array($result)){
$urls[$row[0]] = $row[2];
}
This works fine providing there are only 2 url's in the table, if there are more I get the error message 'The string could not be parsed as XML'
These are the various functions that grab the RSS, aggregate the blogs, and adds the feeds
public function addFeeds( array $feeds )
{
$this->urls = array_merge( $this->urls, array_values($feeds) );
}
public function grabRss()
{
foreach ( $this->urls as $feed )
{
$data = @new SimpleXMLElement( $feed, 0, true );
if ( !$data )
throw new Exception( 'Could not load: ' . $feed );
foreach ( $data->channel->item as $item )
{
$this->data[] = $item;
}
}
}
public function amalgamate()
{
//shuffle( $this->data );
$temp = array();
foreach ( $this->data as $item )
{
if ( !in_array($item->link, $this->links($temp)) )
{
$temp[] = $item;
}
}
$this->data = $temp;
shuffle( $this->data );
}
If anyone can help me out that would be much appreciated