Home > php教程 > php手册 > php使用正则取得域名地址

php使用正则取得域名地址

WBOY
Release: 2016-06-21 08:57:31
Original
1155 people have browsed it

比如域名是alixixi.com,正则表达式如下:

 

$S = 'http://www.alixixi.com/'
$domain = array('com','cn','name','org','net');
$SS = $S;
$dd = implode('|',$domain);
$SS = preg_replace('/(.*)((\w+)(\.('.$dd.'))*\.('.$dd.'))$/iU','$2',$SS);
echo $SS ;



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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template