Tag: Get file extension using PHP

Get file extension using PHP

February 16, 2010 | Filed Under PHP | Comments Off

There are number of way to get file extension in php.
function getFileExtension($filename)
{
$fileinfo= pathinfo($filename);
return $fileinfo['extension'];
}

$ext = end(explode(‘.’, $file));

$ext = substr(strrchr($file, ‘.’), 1);

$ext = substr($file, strrpos($file, '.') + 1);

$ext = preg_replace('/^.*\.([^.]+)$/D',  '$1', $file);

$exts  =split("[/\\.]", $file);

$n = count($exts)-1;
$ext = $exts[$n];
Article written by admin

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker