Hello, I have urls like this:
http://site/search/region,state
and
http://site/type/mytype
I need to extract the last part and echo this. I used code below and for the first url it returns "region,state" (but I only need the last part). And what if behind the url is another character like a slash or the equal sign?
btw: The second url is simply okay. But how do I use basename or explode to also remove the comma?
Preferably I want to use this in a function.
<?php $urlstring = $_SERVER["REQUEST_URI"];
echo basename($urlstring);
$urlstring = explode('/', $urlstring);
$last = array_pop($urlstring);
echo $last ;
?>