I'm trying to linkify URLs inside a text content. I know there are so many questions and answers for this purpose but I have a little bit different situation here.
What I want to do is converting this:
the best search engine is [out: http://google.com google].
into this:
the best search engine is <a href="http://google.com" rel="nofollow">google</a>.
or converting this:
the best search engine is [in: google].
into this:
the best search engine is <a href="http://mywebsite.com/google">google</a>.
What is the easiest way to do this in PHP for a newbie?
The best point I've reached is this:
$message = preg_replace("'(in: (.*))'Ui","(in: <a href=\"link.php?t=\\1\"><b>\\1</b></a>)",$message);
out:andin:? Why is that prefix necessary?http://mywebsite.com/google, just/googlewill behave identically since it will look for an absolute path in the current website