frost Posted September 12, 2007 Share Posted September 12, 2007 $Text = preg_replace("/(http[s]?){1}:\/\/([:a-z_\-\\.\/0-9%~]+){1}(\?[a-z=0-9\-_&;]*)?(\#[a-z0-9]+)?/", " <a href=\"$1://$2$3$4\">$1://$2$3$4</a>", $Text); $Text = preg_replace('/\s(www\.)(\S+)/', ' <a href="http://\\1\\2" target="_blank">\\1\\2</a>', $Text); echo stripslashes($Text); I was able to slap together these 2 replacements for changing plain text links into active links. One finds all the text with http and the second finds the www text. I was wondering if there is a better way to do this? Cheers. Link to comment https://forums.phpfreaks.com/topic/69050-better-way/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.