Getting File Extension Using PHP

Quick post, more as a reference for myself, of how to get the extension of a file using PHP.

Discovered a great post on Cowburn.info outlining the various ways to do this and the time implications, ending up with:

$filename = 'mypic.gif';
$ext = pathinfo($filename, PATHINFO_EXTENSION);

being the best option.

Leave a Reply

Your email address will not be published. Required fields are marked *