I want to make it so that in my chat-application, links to websites can be clickable and links to YouTube and images automatically gets embedded.
I\'ve made this cod
I had some issues with the preg_replace_callback
when the text included three dots ...
. The above code recognized the three dots as a URL which is not true.
Here is my fix and it seems to work at the moment $str = preg_replace_callback('#(?:https?://\S+)|(?:www.\S+)|(?:jpe?g|png|gif)#', function($arr)
Would this fix fail in other cases???