I'm getting texts from my database, I wanted to know, if there is any link inside this text, how do I make it appear as a normal link to everyone?
I'm getting texts from my database, I wanted to know, if there is any link inside this text, how do I make it appear as a normal link to everyone?
Basically you will need to do a replace
~[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]~
$texto = "Oi, sou Mauro, costumo acessar vários sites como http://www.facebook.com";
$texto = preg_replace(
"~[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]~",
"<a href=\"\0\">\0</a>", $texto
);
echo $texto;
See it working: link
If you do not want to reinvent the wheel, there are some libs
that do this work for you, these are the ones I use / recommend and recommend.