PHP: Get File Extension
There are many ways to get the file extension of a file. Here is an example of a php function I found to do just that.
<?php
function file_extension($fname)
{
$path_info = pathinfo($fname);
return $path_info[‘extension’];
}
?>
function file_extension($fname)
{
$path_info = pathinfo($fname);
return $path_info[‘extension’];
}
?>
Another way would be to check the actual string and use what’s after the last slash. I picked this up on a forum I visit.






Another option is to do something like:
pathinfo work great. Substring example doesn’t work when you have a file like db.class.php