Easy PHP File Extensions With PathInfo

The other day I was building some file handling functionality into a project I was working on when i came to thinking about the best way to retrieve the extension of a filename with PHP.

The first approach that came to mind was using explode statement to split the string at the full stop giving the extension of the file in the last array element. The second was using substr and strrchr in combination similar to below: