This is a question you can read everywhere on the web with various answers:
$ext = end(explode(\'.\', $filename)); $ext = substr(strrchr($filename, \'.\'), 1
pathinfo is an array. We can check directory name, file name, extension, etc.:
$path_parts = pathinfo('test.png'); echo $path_parts['extension'], "\n"; echo $path_parts['dirname'], "\n"; echo $path_parts['basename'], "\n"; echo $path_parts['filename'], "\n";