I have a string with a URL in it.
I need to be able to detect is, change to link and encode.
$str = 'some text here domain.com/dir?file more text...';
I can detect and convert it to link by doing this:
preg_replace("/(http:\/\/|(www\.))(([^\s<]{4,68})[^\s<]*)/", '<a href="/dir/$2$3" rel="nofollow">$2$4</a>', $str);
However, this will produce only a link
I need to be able to encode http://domain.com/dir?file using base64_encode.
I think I'm pretty close here but need help putting it all together. Kinda stuck...