PHP: link URL’s inside text

$regex = '@(https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?)@';
$line = preg_replace_callback($regex, "createlink", $text);
// Replace a link
$line = preg_replace_callback('#\<a href="(.*)">(.*)#Ui', "replace", $text); </a>

Leave a Reply