How to get the last 2 directories from a URL using PHP ???

Hi all. Can any one tell me how to get the last 2 directories from a URL using php

just now i am using

(btw im not allowed to post to external links so i cant show the actual link to the site

code:

 preg_match(/(http://)(.*).html/, "basepathtodirectory using http path/2010/12/end-of-week-3-update-patch-143-closed.html", $link);

 $path_parts = pathinfo($link[0]);

and i get the full url.. i just want $url to equal the path to the last 2 directories

so $path_parts will be just

/2010/12/end-of-week-3-update-patch-143-closed.html

Any help would be great!!

Topic Replies: 0

This entry was posted in answer. Bookmark the permalink.

Leave a Reply