
Getting a file extensions from a PHP string is an important task on validating a file for a upload. For example if you have a file uploader which you only want to use for image uploads then you need to validate the file extension is of an image extension.
Here is a PHP function to get the extension of a string. It will explode the string on any “.” and get the last of the array.

