i'm using simplepie to get feeds and display them on my page. i have the following code that gets feed urls from a db for the code, but what i need is so that the feed urls are formatted as so:
$feed = new SimplePie();
$feed->set_feed_url(array(
'http://feeds.delicious.com/rss/cmccomas80',
'http://feeds.feedburner.com/feedchris'
));
$feed->init();
$feed->handle_content_type();
here's my php code:
<?php
// Include the SimplePie library
require_once 'simplepie.inc';
require 'shorten.php';
require_once 'idn/idna_convert.class.php';
mysql_connect(localhost,$db_username,$db_password);
@mysql_select_db($db_name) or die( "Unable to select database");
$query="SELECT rssfeed FROM members WHERE rssfeed!=''";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$rssfeed=mysql_result($result,$i,"rssfeed");
// Initialize some feeds for use.
$feed = new SimplePie();
$feed->set_feed_url(array(
$rssfeed,
));
// Initialize the feed object
$feed->init();
// This will work if all of the feeds accept the same settings.
$feed->handle_content_type();
?>
<?php if ($feed->error): ?>
<p><?=$feed->error()?></p>
<?php endif ?>
<?php
// Let's loop through each item in the feed.
foreach($feed->get_items(0,1) as $item):
// Let's give ourselves a reference to the parent $feed object for this particular item.
$feed = $item->get_feed();
?>
<h3><a href="<?php echo $item->get_permalink(); ?>" target="_blank"><?php echo html_entity_decode($item->get_title(), ENT_QUOTES, 'UTF-8'); ?></a></h3>
<?php echo $item->get_description();
?>
<p class="footnote"><a href="<?php echo $feed->get_permalink(); ?>" target="_blank"><?php echo $feed->get_title(); ?></a> | <?php echo $item->get_date('M j, Y | g:i a'); ?></p><br />
<?php endforeach;
$i++;
}
?>
I'm just curious on two things:
1) How to get the output to display with the ' before and after the url
2) How to use a comma after all the entries except the last.
Thanks.