Possible Duplicate:
PHP Get end string on url between / and /
I have this code to get the last part of the url between / and / at the end.
The url is:
http://mydomain.com/category/mobile/
I need to retrieve “mobile” from it.
The code i’m using is:
$url = trim($url, '/');
//Put it in a variable
$the_category = substr($url, strrpos($url, '/'));
//whats in it?
echo $the_category;
The above returns nothing … any ideas?
You should explode an array using “/” as the delimiter and then get the last value of the array, like so: