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 wo
Use basename, which was created for this exact purpose.
May be Late...
The Easiest way inbuilt in PHP to grab the last string after last /
could be by simply using the pathinfo
function.
In fact, you could check this for yourself,
$urlString = 'path/to/my/xximage.png';
$info = pathinfo($urlString);
You could do:
var_dump($info);
this will give you something like:
'dirname' => string 'path/to/my/'
'basename' => string 'xximage.png'
'extension' => string 'png' (length=3)
'filename' => string 'xximage'
so to extract the images out of that link you could do:
$img=$info['basename'];
$extension=$info['extension'];
///etc...
echo $img.".".$extension; //xximage.png
Something small, but can make you Grow_Gray_Hair_Prematurely