items as $item) { // limit the number of tweets displayed if ($tweets_to_display > 0) { if ($count > $tweets_to_display) { continue; } } $tweet = $item['description']; // ignore tweets linking back to page (if it is defined) if ($page != "") { if (!strpos($tweet, $page) === false) { continue; } } // figure out how recently the tweet was posted $when = ($now - strtotime($item['pubdate'])); $posted = ""; if ($when < 60) { $posted = $when . " seconds ago"; } if (($posted == "") & ($when < 3600)) { $posted = "about " . (floor($when / 60)) . " minutes ago"; } if (($posted == "") & ($when < 7200)) { $posted = "about 1 hour ago"; } if (($posted == "") & ($when < 86400)) { $posted = "about " . (floor($when / 3600)) . " hours ago"; } if (($posted == "") & ($when < 172800)) { $posted = "about 1 day ago"; } if ($posted == "") { $posted = (floor($when / 86400)) . " days ago"; } // filter the user's username out of tweets $tweet = str_replace($username . ": ", "", $tweet); // turn URLs into hyperlinks $tweet = preg_replace("/(http:\/\/)(.*?)\/([\w\.\/\&\=\?\-\,\:\;\#\_\~\%\+]*)/", "Link", $tweet); // link to users in replies $tweet = preg_replace("(@([a-zA-Z0-9\_]+))", "\\0", $tweet); // add the time posted $tweet = $tweet . " " . $posted . ""; echo ("\n\n

" . $tweet); $count++; } // display output ob_end_flush(); ?>