Omotayo Omotayo - 5 months ago 26
PHP Question

PHP Remove http and web domain from url

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

Answer Source

Here with parse_url() function.

parse_url('http://www.loadedcamp.net/music/63637-adele-hello', PHP_URL_PATH);

Output: /music/63637-adele-hello