Twitter enhancement
The code below enhances the substr function by adding the needle haystack strrchr function. It uses the 'description' as haystack and ':' as needle. Together with substr it eliminates the characters twitterauthor: without having to specify the amount of characters. This is useful if multiple authors would like to use this block.
<?php
$fid = 1; // Feed id
$limit = 5; // Number of tweets in the list
$result = db_query('SELECT link, description, timestamp FROM {aggregator_item} WHERE fid = %d ORDER BY timestamp DESC LIMIT 0,' .$limit, $fid);
while($row = db_fetch_object($result)) {
print '<p class="twitter_status"><a href="'.($row->link).'">'.substr(strrchr("$row->description",":"), 1).'</a> <span class="twitter_status_time">'.twitter_ago($row->timestamp).'</span></p>';
}
function twitter_ago($timestamp){
$difference = time() - $timestamp;
$text = format_interval($difference, 2) . " ago";
return $text;
}
?>