This is a question you can read everywhere on the web with various answers:
$ext = end(explode(\'.\', $filename)); $ext = substr(strrchr($filename, \'.\'), 1
The simplest way to get file extension in PHP is to use PHP's built-in function pathinfo.
$file_ext = pathinfo('your_file_name_here', PATHINFO_EXTENSION); echo ($file_ext); // The output should be the extension of the file e.g., png, gif, or html