DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Get File Extension
function file_extension($filename)
{
$path_info = pathinfo($filename);
return $path_info['extension'];
}






Comments
Snippets Manager replied on Fri, 2010/12/10 - 4:25pm
Snippets Manager replied on Thu, 2012/01/19 - 11:29am
$filename = "my-directory/my-file-name.php" $extension = pathinfo($filename, PATHINFO_EXTENSION);see http://cowburn.info/2008/01/13/get-file-extension-comparison/Snippets Manager replied on Tue, 2009/09/08 - 1:12pm
Snippets Manager replied on Sat, 2009/09/05 - 10:30am
Snippets Manager replied on Mon, 2009/04/13 - 8:51pm
Snippets Manager replied on Mon, 2012/05/07 - 2:29pm
Snippets Manager replied on Fri, 2008/12/05 - 6:41pm
Snippets Manager replied on Sat, 2006/11/04 - 6:41am
Snippets Manager replied on Mon, 2006/10/16 - 6:57pm
function file_extension($filename) { return end(explode(".", $filename)); }Snippets Manager replied on Mon, 2006/10/16 - 6:57pm