[eluser]Zack Kitzmiller[/eluser]
Parse a Tweet. Supports hash tags, @replies, and URLS.
Code:
if (!function_exists('parse_tweet'))
{
function parse_tweet($tweet)
{
$search = array('|(http://[^ ]+)|', '/(^|[^a-z0-9_])@([a-z0-9_]+)/i', '/(^|[^a-z0-9_])#([a-z0-9_]+)/i');
$replace = array('<a href="$1">$1</a>', '$1<a href="http://twitter.com/$2">@$2</a>', '$1<a href="http://search.twitter.com/search?q=#$2">#$2</a>');
$tweet = preg_replace($search, $replace, $tweet);
return $tweet;
}
}