我希望在网址中删除http和网络域并渲染其余的
网址|预期结果
http://www.loadedcamp.net/images/featured/2017/06/1497262523-How_to_Avoid_Adultery_in_Your_Marriage.jpg | /images/featured/2017/06/1497262523-How_to_Avoid_Adultery_in_Your_Marriage.jpg
http://www.loadedcamp.net/music/63637-adele-hello | /音乐/ 63637-Adele的问候
答案 0 :(得分:2)
你可以使用php parse_url()
方法获取url的完整信息。
$foo = "http://www.loadedcamp.net/music/63637-adele-hello";
$blah = parse_url($foo);
print_r($blah);
Array
(
[scheme] => http
[host] => www.loadedcamp.net
[path] => /music/63637-adele-hello
[query] =>
)
print_r($blah['path']);//prints /music/63637-adele-hello
您也可以像这样使用
evho parse_url('http://www.loadedcamp.net/music/63637-adele-hello', PHP_URL_PATH);//prints /music/63637-adele-hello
答案 1 :(得分:2)
此处使用parse_url()
功能。
parse_url('http://www.loadedcamp.net/music/63637-adele-hello', PHP_URL_PATH);
输出:/music/63637-adele-hello