Use strrpos – same as strpos but in reverse. Find the last occurence of ‘/’ then move forward one position and then substr from that position onwards to the end of the string.

<?php echo substr($url,strrpos($url,'/')+1); ?>

How to get the Filename out of a directory name using PHP

Leave a Reply

Your email address will not be published. Required fields are marked *

78 − = sixty nine