PHP实例教程,如何截取一个URL中的主域名,如下代码:
$S = 'http://bbs.webjx.com';
$S = parse_url($S);
$S = strtolower($S['host']) ; //取域名部分
//echo $S;
$domain = array('com','cn','name','org','net'); //域名后缀 有新的就扩展这吧
$SS = $S;
$dd = implode('',$domain);
$SS = preg_replace('/(\.('.$dd.'))*\.('.$dd.')$/iU','',$SS); 把后面的域名后缀部分去掉
$SS = explode('.',$SS);
$SS = array_pop($SS); //取最后的主域名
$SS = substr($S,strrpos($S,$SS)); //加上后缀拼成完成的主域名
echo $SS;
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
