feed_url($url); //$feed->cache_location(‘/cache’); $feed->cache_max_minutes(30); $feed->replace_headers(true); $feed->init(); // We're going to loop through the items in the feed; starting at the beginning, and returning a max of 10 items. foreach ($feed->get_items(0, 3) as $item) { /* * We're going to take data from the $item and put it together into a single string, delimiting each chunk * with five colons (you can delimit however you want, but it's unlikely that you'll come across five * consecutive colons in the content of a feed). */ // Start with a blank slate $data = ''; // We're going to start with milliseconds since Unix epoch (this is the datestamp that we'll sort by) $data .= $item->get_date('U') . ':::::'; // We'll choose a single timezone (GMT) to base all dates/times on. $data .= gmdate('j M Y | g:ia \G\M\T', $item->get_date('U')) . ':::::'; // Get the title of the posting $data .= $item->get_title() . ':::::'; // Get the permalink for the posting $data .= $item->get_permalink() . ':::::'; // Get the description content for the posting $data .= $item->get_description() . ':::::'; // Besides $item data, we'll also get the title of the $feed we're pulling this from $data .= $feed->get_feed_title() . ':::::'; // Lastly, we'll get the permalink to the $feed that we're pulling this from. // Since it's the last one, we don't need to add the delimiter to the end. $data .= $feed->get_feed_link(); // Place this whole thing into the next available spot in the $multifeeds array. $multifeeds[] = $data; } // We're done with $feed for this round of the loop, so we'll wipe it out so we can loop back and start fresh. unset($feed); } // When we're done looping through the feeds and collecting our data, we'll reverse sort all of the feeds by seconds since Unix epoch (newest to oldest) rsort($multifeeds); ?>