Extract the extension from a filename

This is a simple technique to extract the filename extension from a filename.  It could easily be adapted to extract the filename from a path or a query string from a URL by changing the first parameter of the explode() function.

$extension = end(explode('.', $filename));

Leave a Reply