Created
June 19, 2014 07:23
-
-
Save Robbertdk/ef28a67575caf9dfafaf to your computer and use it in GitHub Desktop.
Linkify Twitter JSON feed, via http://davidwalsh.name/linkify-twitter-feed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function linkify($status_text){ | |
// linkify URLs | |
$status_text = preg_replace( | |
'/(https?:\/\/\S+)/', | |
'<a href="\1">\1</a>', | |
$status_text | |
); | |
// linkify twitter users | |
$status_text = preg_replace( | |
'/(^|\s)@(\w+)/', | |
'\1@<a href="http://twitter.com/\2">\2</a>', | |
$status_text | |
); | |
// linkify tags | |
$status_text = preg_replace( | |
'/(^|\s)#(\w+)/', | |
'\1#<a href="http://search.twitter.com/search?q=%23\2">\2</a>', | |
$status_text | |
); | |
return $status_text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment