Lambneck Posted August 10, 2009 Share Posted August 10, 2009 Hi on my blog when I submit a post containg a hyperlink such as: http://us.php.net/ It shows up on the post as text and not a clickable link. How can I make it so it will be a clickable link? Link to comment https://forums.phpfreaks.com/topic/169561-solved-allowing-hyperlinks/ Share on other sites More sharing options...
scvinodkumar Posted August 10, 2009 Share Posted August 10, 2009 $text = "Hello World. Today I visited http://www.google.com/ for the first time"; $text = preg_replace("/(http:\/\/(.*)\/)[\S]*/", "<a href=\\1>\\1</a> ", $text); Link to comment https://forums.phpfreaks.com/topic/169561-solved-allowing-hyperlinks/#findComment-894617 Share on other sites More sharing options...
Lambneck Posted August 10, 2009 Author Share Posted August 10, 2009 Hi, that almost works.. Its turning the text into link but changes what the link says. I want to retain the original structure of the link while at the same time making in a working hyper link. Link to comment https://forums.phpfreaks.com/topic/169561-solved-allowing-hyperlinks/#findComment-894637 Share on other sites More sharing options...
Lambneck Posted August 10, 2009 Author Share Posted August 10, 2009 Ok so I'm using the following and getting what I want except when i click the link it creates a <br /> at the end of the url in the address bar! ex: http://www.google.com/analytics<br /> Why could it be doing that? And how do I get rid of it? $message = preg_replace('/((www|http:\/\/)[^ ]+)/', '<a href="\1">\1</a>', $row['message']); Link to comment https://forums.phpfreaks.com/topic/169561-solved-allowing-hyperlinks/#findComment-894675 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.