Any ideas on how to removee the last folder from a given URL. For example:
www.example.com/test1/test2/test3
I want to remove only test3
Remove the last directory from URL
Moderator: General Moderators
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: Remove the last directory from URL
Perhaps a regular expression? Read any valid characters then when you come across a '/' check for any further characters?
I'm no regex expert though, so you're on your own there!
I'm no regex expert though, so you're on your own there!
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: Remove the last directory from URL
Thnx man.
I found it out myself using strrpos().
I found it out myself using strrpos().
Re: Remove the last directory from URL
basename() might be the simplest.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.