php如何提取域名的根部分

WBOY
Release: 2016-06-13 13:04:54
Original
787 people have browsed it

php怎么提取域名的根部分
怎么提取域名的根部分 比如 ww1.baidu.com dy.baidu.com  a.www.baidu.com  提取baidu.com这部分
------最佳解决方案--------------------
用.切数组,然后逆向foreach,一旦某一个点不是已知的顶级域名或者国家域名,则是你所谓的根部分
------其他解决方案--------------------
$url = 'http://dy.baidu.com';
print_r(parse_url($url));

打印出来的数组里有你想要的数据。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template