[英]PHP Remove http and web domain from url
I want http and web domain removed in a url and render the rest 我想在网址中删除http和网络域,然后呈现其余部分
URL | 网址| Expected result 预期结果
http://www.loadedcamp.net/images/featured/2017/06/1497262523-How_to_Avoid_Adultery_in_Your_Marriage.jpg | 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 /images/featured/2017/06/1497262523-How_to_Avoid_Adultery_in_Your_Marriage.jpg
http://www.loadedcamp.net/music/63637-adele-hello | http://www.loadedcamp.net/music/63637-adele-hello | /music/63637-adele-hello / music / 63637-adele-hello
you can php parse_url()
method to get the complete info of url as. 您可以使用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
you can also use like this 你也可以这样使用
evho parse_url('http://www.loadedcamp.net/music/63637-adele-hello', PHP_URL_PATH);//prints /music/63637-adele-hello
Here with parse_url()
function. 这里带有parse_url()
函数。
parse_url('http://www.loadedcamp.net/music/63637-adele-hello', PHP_URL_PATH);
Output: /music/63637-adele-hello
输出: /music/63637-adele-hello
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.