If you need the last element of the array, do the following:
$arr = explode(".", $file_name);
$file_ext = $arr[count($arr) - 1];
If you are trying to just get the extension from a file, use
$ext = pathinfo($file_name, PATHINFO_EXTENSION);
source
share