OK, this is what I’m trying to do (it’s quite a quickie actually, but decided to post in case we come up with something smarter… :-))
- Get a URL like : http://www.somedomain.com/subfolder/yet-another-subfolder/final.php?param=2
- Retrieve just this part : http://www.somedomain.com/subfolder/yet-another-subfolder/
That’s what I was thinking of :
function getMainPart($url)
{
$parts = explode("/",$url);
return str_replace(end($parts),"",$url);
}
Do you have anything… smarter or better to suggest? Any ideas? (Or anything more universal/directly-supported-by-PHP?)
The “right” (albeit a lot more long-winded) way to do it: