I know it has a lot of posts here to convert text link into clickable ones. But my situation is a little different.
I'd like to convert only links from my website. Not other websites.
So I tried:
$text = "The text you want to filter goes here. http://example.com/site/site";
echo preg_replace('$(\s|^)(https?://[example.com]+)(?![^<>]*>)$i', ' <a href="$2" target="_blank">$2</a> ', $text." ");
It works, but the problem is if the url contains something like: www.example.com/example/article/01/3232/ if will only get the example.com.
any ideas how to make it work as I want?