Roeland Roeland - 3 months ago 9
PHP Question

Grab remaining text after last "/" in a php string

So, lets say I have a

$somestring
thats holds the value "main/physician/physician_view".

I want to grab just "physician_view". I want it to also work if the passed string was "main/physician_view" or "site/main/physician/physician_view".

Hopefully my question makes sense. Any help would be appreciated!

Answer

There are many ways to do this. I would probably use:

array_pop(explode('/', $string));
Comments