Method 1
function findexts ($filename) {
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
Method 2
$filename = 'mypic.gif';
$ext = pathinfo($filename, PATHINFO_EXTENSION);
Method 3
function getFileextension($file) {
return end(explode(".", $file));
}
I always use latest method
Yo,
This method won’t work anymore, “split” is depreciated, you need to replace with “explode” instead.
Only trouble i am having is now that i use explode, it displays the filename followed by the extension, not just the extension on its own.