好的,如果我有网址http://hello.com/api/thispart.php
如何让preg_match()函数只选择thispart
到目前为止,我正在寻找
preg_match('@^(?:http://)?([^/]+)@', "http://hello.com/api/thispart.php", $matches)
echo " <br>Domain name is: $matches[0] <br>";
echo " <br>Domain name is: $matches[1];
输出
Domain name is: http://hello.com
Domain name is: hello.com
但我只想输出thispart