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;
}
}
?>

I'm confused :)

Do you mean you want to parse another XML feed or display extra information for your current feed?

It may help if you do a print_r on your feed data to see all available information of have to work with:

<pre>
<?= print_r($feeds->data); die(); ?>
</pre>

Sorry I may not of explained it very well, within the

<?php echo $description; ?>

variable there is a link to an mp3 file, instead of displaying the entire description I just want to display that mp3 link, is this possible?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.