随笔记录 蓝优 2020-10-30
<?php echo Domain('https://www.baidu.com/'); //匹配一级域名 function Domain($wd){ preg_match_all('/(http(s)?:\/\/)?([^.]+\.)?((.*)\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})/',$wd,$json); $value = $json[4][0]; return $value; }