I want http and web domain removed in a url and render the rest
URL | Expected result
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 | /music/63637-adele-hello
you can php parse_url()
method to get the complete info of url as.
$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('http://www.loadedcamp.net/music/63637-adele-hello', PHP_URL_PATH);
Output: /music/63637-adele-hello
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.