Extracting a File Extension From a Path

Problem

You want to quickly determine a file's extension.

Solution

Use the File::extension() method.

$extension = File::extension($filename);

If there is no extension, an empty string is returned. Otherwise, a string containing everything after the last period in the filename is returned.

Discussion

No discussion needed.

comments powered by Disqus