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? Quote Link to comment 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); Quote Link to comment 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. Quote Link to comment 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']); 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.