使用PHP获取URL中的最后一个值

I was wondering how can I grab the last value in a url for example how can I grab the value someone in the url below using PHP. Can someone help me do this?

http://www.example.com/questions/ask/someone

Not too hard:

echo basename($url);

As a side note, you can also use dirname to get the remainder of the content.

$url = "http://www.example.com/questions/ask/someone";
echo basename($url);  // someone
echo dirname($url);   // http://www.example.com/questions/ask

search the position of Last slash then make a new substring from the index position of slash to end.It's as simple.