Possible Duplicate:
How to get the last path in the url?
I’m not very good with regex as I haven’t yet come to understand how it fully works to get the right results. I need a regex expression or php function to strip out the beginning of a url to get the last bit without the variables on it.
Input : http: // http://www.site.com/more/more/thepartidneed?part=Idontneed
Other Input : http://www.site.com/more/more/thepartineed?partidontneed
Other input : site.com/more/more/partineed
Results Desired After Stripped :
“thepartineed”
Is this possible?
First you need to check if given URL contains
http(s)://at the beginning, if not – append it and then doYou will get something like this:
If you need only last bit of path you can do