Getting a List of All Files in a Directory

Problem

You want to pull a list of all files in a directory.

Solution

Use the File::files() method.

$files = File::files();

Discussion

This method always returns an array.

The array only contains files, no directories.

If no files are found in the directory, or the directory doesn't exist, an empty array is returned.

comments powered by Disqus