Q:

PHP Get end string on url between / and /

I need to get the last string content of the url between / and /
For example:
http://mydomain.com/get_this/

or

http://mydomain.com/lists/get_this/

I need to get where get_this is in the url.

A:

trim() removes the trailing slash, strrpos() finds the last occurrence of / (after it's trimmed), and substr() gets all content after the last occurrence of /.
$url = trim($url, '/');
echo substr($url, strrpos($url, '/')+1);

View output

Even better, you can just use basename(), like hakre suggested:
echo basename($url);

View output

