<?php function GetContentBetween($StringToParse, $StartMarker, $EndMarker) { // Look to see if our beginning marker is in the string $StartMarkerPosition = strpos($StringToParse, $StartMarker); // Look to see if our end marker is in the string $EndMarkerPosition = strpos($StringToParse, $EndMarker); // If we found both markers, proceed to truncate the string to just the content // between the markers if ($StartMarkerPosition === false && $EndMarkerPosition === false) { $Results = false; } else { $StartMarkerPosition = $StartMarkerPosition + strlen($StartMarker); $EndMarkerPosition = $EndMarkerPosition - $StartMarkerPosition; $Results = substr($StringToParse, $StartMarkerPosition, $EndMarkerPosition); } return $Results; } $url = file_get_contents('http://localhost:8888/feeds/developer-activity.php'); $url = strip_tags($url, '<a>'); echo GetContentBetween($url, 'Author:', 'Date:'); ?>
<ul id="developerActivity"> <?php /* Here, we'll loop through all of the items in the feed, and $item represents the current item in the loop. */ foreach ($feed->get_items() as $item) { $feedConent = ""; $feedContent = $item->get_content(); $feedContent = strip_tags($feedContent, '<a>'); // Fix a bug in the Launchpad RSS that malforms links to users $feedContent = str_replace('https://launchpad.nethttps:0//launchpad.net/', 'http://launchpad.net/', $feedContent); ?> <li><?php echo GetContentBetween($feedContent, "Author:", "Date:"); ?> recently made a contribution to <?php echo GetContentBetween($feedContent, "Project:", "Log message:"); ?> <span>r<?php echo GetContentBetween($feedContent, "Revno:", "Project:"); ?> </span></li> <?php } ?> </ul>