Expand|Select|Wrap|Line Numbers
- private function hyperlink($text) {
- // match protocol://address/path/
- $text = ereg_replace("[a-zA-Z]+://([.]?[a-zA-Z0-9_/-])*", "<a href=\"\\0\">\\0</a>", $text);
- // match www.something
- $text = ereg_replace("(^| )(www([.]?[a-zA-Z0-9_/-])*)", "\\1<a href=\"http://\\2\">\\2</a>", $text);
- // match @replys
- $text = preg_replace("/[@]+[A-Za-z0-9-_]+/", "<a href=\"http://twitter.com/\\0\">\\0</a>", $text);
- // match #hashtags
- $text = preg_replace("/[#]+[A-Za-z0-9-_]+/", "<a href=\"http://search.twitter.com/search?q=\\0\">\\0</a>", $text);
- // fix Twitter URLs
- $text= str_replace("<a href=\"http://twitter.com/@","<a target=\"_blank\" href=\"http://twitter.com/",$text);
- $text= str_replace("<a href=\"http://search.twitter.com/search?q=#","<a target=\"_blank\" class=\"hashtag\" href=\"http://search.twitter.com/search?q=%23",$text);
- // return $text
- return $text;
- }
http://example.com/blah?question=answer. If somebody could modify it to make it work with those I would be extremely grateful. Also, if it's not to difficult, it would be extremely beneficial to have it parse blip urls in the form
http://blip.com/~7cwjhThanks a bunch guys!