How to

How to get a file extension with PHP

The following script makes it more easy to get the file extension from a file name:

In case you have the ability to use mime type detection, you could combine it with the above function to validate if the extension is valid for the content of the file.