N
A
T
A
S
H
ASHIAGBOR
How to make plain URL in string clickable in PHP
Hi :)
This is just a quick PHP function to make all plain URL found in a string clickable. Very useful for projects where you want users to be able to click on any links found within text contents.
function make_links_clickable($text) { // The Regular Expression filter $pattern = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; $text = preg_replace($pattern, "\\0", $text); return $text; }
Good luck