已知字符串
https://open.weixin.qq.com/cgi-bin/frame?t=home/app_tmpl&lang=zh_CN
从上面这段url字符串中,提取出 qq.com
或者 weixin.qq.com
function checkUrls($domain)
{
$domain = '`https://open.weixin.qq.com/cgi-bin/frame?t=home/app_tmpl&lang=zh_CN`';
$httpurl = strtolower(trim($domain));
if (empty($httpurl)) return;
$regx1 = '/https?:\/\/(([^\/\?#]+\.)?([^\/\?#-\.]+\.)(com\.cn|org\.cn|net\.cn|com\.jp|co\.jp|com\.kr|com\.tw)(\:[0-9]+)?)/i';
$regx2 = '/https?:\/\/(([^\/\?#]+\.)?([^\/\?#-\.]+\.)(cn|com|org|net|cc|biz|hk|jp|kr|name|me|tw|la)(\:[0-9]+)?)/i';
$host = '';
if (preg_match($regx1, $httpurl, $matches)) {
$host = $matches[3] . $matches[4];
} elseif (preg_match($regx2, $httpurl, $matches)) {
$host = $matches[3] . $matches[4];
}
return $host
}