Reputation: 7351
Say I have a url like this in a php variable:
$url = "http://mywebsite.extension/names/level/etc/page/x";
how would I automatically remove everything after the .com
(or other extension) and before /page/2
?
Basically I would like every url that could be in $url to become http://mywebsite.extension/page/x
Is there a way to do this in php? :s
thanks for your help guys!
Upvotes: 1
Views: 999
Reputation: 39522
I think parse_url()
is the function you're looking for. You can use it to break down an URL into it's component parts, and then put it back together however you want, adding in your own things as needed.
As PeeHaa noted, explode()
will be useful for dividing up the path.
Upvotes: 3