PHP假人在这里.
比方说,我有我的域名是这样的:http://www.domain.com/somefolder/index.html所以现在我需要像这样:somefolder/index.html
为此,我使用以下代码:
<?php $urlparts = parse_url("http://www.domain.com/somefolder/index.html");
$extracted = $urlparts['path'];
print $extracted;?>
Run Code Online (Sandbox Code Playgroud)
现在我得到这样的输出:/somefolder/index.html
我喜欢做的是只删除第一个斜杠,使它看起来像这样:
somefolder/index.html如果我可以获得相同的结果(在第一个文件夹上删除斜杠但不是即使我有更多像这样的文件夹:other_folder/somefolder/index.html或者other_folder/yet_another_folder/somefolder/index.html.
有没有一个可以像我一样帮助假人的好人?谢谢!