I want to remove te first part of the url in PHP. Example:
http://www.domain.com/sales
http://otherdomain.org/myfolder/seconddir
/directory
must be:
/sales
/myfolder/seconddir
/directory
Because the url in dynamic, I think I have to do this with preg replace, but I don't know how.. And sometimes the url is already removed (see last example). How to do this?
Try:
And have a look at:
http://php.net/manual/en/function.parse-url.php
you could use path info:
the output:
good luck!
There is a built in php function for this parse_url.
From the linked website:
The above example will output: