Ok, I'm stumped! I need to get the highest folder name in the URL, such as the examples below:

www.fakesite.com/folder/this
www.fakesite.com/folder/file/this/
www.fakesite.com/this/index.html

will all yield 'this'.

How do I approach this using PHP or JavaScript?

Thanks,
M