This is a question you can read everywhere on the web with various answers:
$ext = end(explode(\'.\', $filename)); $ext = substr(strrchr($filename, \'.\'), 1
Here is an example. Suppose $filename is "example.txt",
$ext = substr($filename, strrpos($filename, '.', -1), strlen($filename));
So $ext will be ".txt".