Never been to DZone Snippets before?

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 (See related posts)

function file_extension($filename)
{
    $path_info = pathinfo($filename);
    return $path_info['extension'];
}

Comments on this post

albert006 posts on Oct 16, 2006 at 19:05
Maybe faster:

function file_extension($filename)
{
return end(explode(".", $filename));
}
albert006 posts on Oct 16, 2006 at 19:06
Sorry I didn't use code formatting:

function file_extension($filename)
{
    return end(explode(".", $filename));
}
Solid posts on Nov 04, 2006 at 05:49
Not faster, but slower in 0.5 times.

You need to create an account or log in to post comments to this site.


Click here to browse all 4860 code snippets

Related Posts