Encode flat text URL to clickable URL

Solution 1:

This solution will catch all http/https/www and convert to clickable links.

Convert plain text URLs into HTML hyperlinks in PHP

$url = '/(http|https|ftp|ftps)://[a-zA-Z0-9-.]+.[a-zA-Z]{2,3}(/\S*)?/';
$string= preg_replace($url, '$0', $string); echo $string;