I have a script which is parsing xml code and displayed the title of blog posts, the date, and a breif extract from each post. However I also want to show any mp3 links within that blog post too but I am not sure how to do this. If anyone has any ideas then that would be fantastic
this is the current script
<?php
class Feed_Amalgamator
{
public $urls = array();
public $data = array();
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 );
}
private function links( array $items )
{
$links = array();
foreach ( $items as $item )
{
$links[] = $item->link;
}
return $links;
}
}
//adding feeds urls to an array
$getUrls = "SELECT * FROM sscape_blogroll";
$result = mysql_query($getUrls);
$urls = array();
while($row = mysql_fetch_array($result)){
$urls[$row[0]] = $row[2];
}
try
{
$feeds = new Feed_Amalgamator;
$feeds->addFeeds( $urls );
$feeds->grabRss();
$feeds->amalgamate();
}
catch ( exception $e )
{
die( $e->getMessage() );
}
$count_limit = 0;
$limit = 6;
foreach ( $feeds->data as $item ) {
extract( (array) $item );
if($count_limit++ < $limit){
?>
<div id="post"><p class="title"><a href="<?php echo $link; ?>"><?php echo $title; ?></a></p>
<p class="date"><?php echo $pubDate; ?></p>
<p class="extract"><?php echo $description; ?></p></div>
<? }
else {
break;
}
}
?>