PHP something faster than explode to get filename from URL
Posted
by FFish
on Stack Overflow
See other posts from Stack Overflow
or by FFish
Published on 2010-05-16T18:38:15Z
Indexed on
2010/05/16
18:40 UTC
Read the original article
Hit count: 191
My URL's can be absolute or relative:
$rel = "date/album/001.jpg";
$abs = "http://www.site.com/date/album/image.jpg";
function getFilename($url) {
$imgName = explode("/", $url);
$imgName = $imgName[count($imgName) - 1];
echo $imgName;
}
There must be a faster way to do this right? Maybe a reg expression? But that's Chinese to me..
© Stack Overflow or respective owner