function formatURL($text) { $normal= '/^http?:\/\/[a-z0-9-]+(\.[a-z0-9-]+)+/i'; $secure= '/^https:\/\/[a-z0-9-]+(\.[a-z0-9-]+)+/i'; if (preg_match($secure, $text)): return $text; else: if (preg_match($normal, $text)): return $text; else: return "http://".$text; endif; endif; }