<?php
$file = 'file.txt';
function getFileextension($file) {
       return end(explode(".", $file));
}
?>

Source: http://css-tricks.com/snippets/php/find-file-extension/