Rifts Posted December 13, 2010 Share Posted December 13, 2010 Hey guys I need to use preg match for this: I have a paragraph saved to a $var I need to run preg match on the $var and make anything that is http:// into a link so I'm guessing that would require replacing http:// with <a href="that link somehow">the original link and then also adding </a> at the end somehow? any ideas? Quote Link to comment Share on other sites More sharing options...
Rifts Posted December 13, 2010 Author Share Posted December 13, 2010 Ok I found out how to do it but I need help updating this $str2 = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $str1); Quote Link to comment Share on other sites More sharing options...
Rifts Posted December 13, 2010 Author Share Posted December 13, 2010 $str2 = preg_replace("/(http:\/\/[^\s]+)/", "<a href=\"$1\">$1</a>", $str1); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.