$feed) { foreach($feed->get_items() as $item) { $timestamp = strtotime($item->get_date()); //$river[{uniqueIdentifier}][{description of information}] = {the information} //the uniqueIdentifier starts with the timestamp so that when we sort the river into date order it is correct $river[$timestamp.$name]['title'] = $item->get_title(); $river[$timestamp.$name]['link'] = $item->get_link(); $river[$timestamp.$name]['name'] = $item->get_feed()->get_title(); if('flickr'==$name){$river[$timestamp.$name]['bg']=$item->get_content();} $river[$timestamp.$name]['feed'] = $name; $river[$timestamp.$name]['timestamp'] = $timestamp; } } //be magical and sort each item in the river by date krsort($river); /* ensure that there are always 4 items in a row by removing any droplets in a row with less than 4 droplets */ while((!is_int(count($river) / 4))||(36 < count($river))) { array_pop($river); } //identify tweets from youtube foreach($river as $timestamp => $droplet) { if((preg_match('/http:\/\/youtu.be\//i', $droplet['title']))) { $river[$timestamp]['feed'] = 'twitter-youtube'; } } //format the content so it looks good on the page function format_content($content, $feed) { switch($feed) { case 'twitter': return '
'.substr($content, 11).'
'; break; case 'twitter-youtube': return ''.substr(ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","\\0", $content), 11).'
'; break; case 'bg': preg_match_all('/<\s*img\s*\S*src=\s*[\"¦\'](.*?)\s*[\"¦\']/i', $content, $matches); $imgSrc = $matches[1][0]; $imgSrc = str_ireplace('_m', '', $imgSrc); return ' style="background: url('.$imgSrc.') center no-repeat"'; break; case 'posterous': return ''.substr($content, 0, 80).((80<=strlen($content))?'...':null).'
'; break; default: return ''.$content.'
'; break; } } ?>