Skip to content

Instantly share code, notes, and snippets.

@jgv
Created May 13, 2010 16:26
Show Gist options
  • Save jgv/400026 to your computer and use it in GitHub Desktop.
Save jgv/400026 to your computer and use it in GitHub Desktop.
cleaning sloppy rss feed. requires magpie
<div id="sidebar">
<div class="events">
<h2>Public Programs</h2>
<?php
ob_start();
$rss = fetch_rss("http://feeds.feedburner.com/NewMuseumEvents");
$count = 1;
foreach ($rss->items as $item){
if ($count > 3) {
continue;
}
$once = substr($item['title'], 0, strrpos($item['title'], ',', strrpos($item['title'], ',')));
$twice = substr($once, 0, strrpos($once, ','));
$days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
$clean = str_replace($days, '', $twice);
//$trim = substr($title, 0, (strpos($title,'|') - 1)); save this snippet to include the date / time
$strip = strip_tags($clean);
echo "<p class='events'><a href='" . $item['link'] . "'>" . $strip . "</a></p>";
$count++;
}
ob_end_flush();
?>
</div>
<div class="exhibitions">
<h2>On View</h2>
<?
ob_start();
$rss = fetch_rss("http://feeds2.feedburner.com/NewMuseumExhibitions");
$count = 1;
foreach ($rss->items as $item){
if ($count > 3) {
continue;
}
$trim = substr($item['title'], 1, (strrpos($item['title'],'"') -1));
$strip = strip_tags($trim);
echo "<p class='exhibitions'><a href='" . $item['link'] . "'>" . $strip . "</a></p>";
$count++;
}
ob_end_flush();
?> </div> <?php
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : endif; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment