3v4l.org

run code in 300+ PHP versions simultaneously
<?php $reg_exUrl = "/((http|https|ftp|ftps)\:\/\/|(www)\.)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; $text = 'lol http://google.bg is an awesome website;'; if(preg_match($reg_exUrl, $text, $url)) { // make the urls hyper links $new_text = preg_replace($reg_exUrl, '<a href="'.$url[0].'" target="_blank">'.$url[0].'</a> ', $text); } else { // if no urls in the text just return the text echo $text; } echo $new_text;

preferences:
36.94 ms | 402 KiB | 5 Q