PHP: Get filename extension with native PHP function
The extension part of the filename, is what typically tells us what type of file it is. A JPEG image may have the filename "image.jpg", where "jpg" is the extension.
Click through to learn how easy it is to extract this with PHP.
echo pathinfo('filename.jpg', PATHINFO_EXTENSION);
Easy as that! This will output
pathinfo can be used for much more than retrieving the file extension, please see the PHP documentation for all options.