[英]return specific part of url preg_match
Imagine you have this cases 想象你有这种情况
$d='http://www.example.com/';
$d1='http://example.com/';
$d2='http://www.example.com';
$d3='www.example.com/';
$d4='http://www.example.com/';
$d5='http://www.example.com/blabla/blabla.php';
I need to get only example.com and nothing else. 我只需要获得example.com ,别无其他。 I've tried using parse_url to no avail. 我试过使用parse_url无济于事。
Using parse_url($d1, PHP_URL_HOST);
使用parse_url($d1, PHP_URL_HOST);
returns nothing in $d3, for example. 例如,在$ d3中不返回任何内容。
Can any of you provide a ereg to match this? 你们任何人都可以提供一个ereg来匹配它吗?
Thank you very much in advance! 提前非常感谢您!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.