Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The function that links the hashtags, urls and usernames into links...
- function twitterize($raw_text) {
- $output = $raw_text;
- // parse urls;
- $output = preg_replace(
- '@(https?://([-\w\.]+)+(/([\w/_\.]*(\?\S+)?(#\S+)?)?)?)@', '<a href="$1" target="_blank">$1</a>', $output);
- // parse usernames
- $output = preg_replace(
- '/@(\w+)/', '<a href="http://twitter.com/$1" target="_blank">@$1</a>',$output);
- // parse hashtags
- $output = preg_replace(
- '/\s+#(\w+)/', ' <a href="https://twitter.com/search?q=%23$1" target="_blank">#$1</a>', $output);
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement