function valURL($url) { $pattern = '/(https?:\/\/(?:www3?\.)?[^\/]+?\.[^\/]{2,})/'; if (preg_match($pattern, $url)) { //return "works ".$url; return true; } else { //return "doesn't work ".$url; return false; } }