This is a question you can read everywhere on the web with various answers:
$ext = end(explode(\'.\', $filename));
$ext = substr(strrchr($filename, \'.\'), 1
1) If you are using (PHP 5 >= 5.3.6) you can use SplFileInfo::getExtension — Gets the file extension
Example code
getExtension());
$info = new SplFileInfo('test.tar.gz');
var_dump($info->getExtension());
?>
This will output
string(3) "png"
string(2) "gz"
2) Another way of getting the extension if you are using (PHP 4 >= 4.0.3, PHP 5) is pathinfo
Example code
This will output
string(3) "png"
string(2) "gz"
// EDIT: removed a bracket