Getting All the Directories in a Directory


You want to get a list of all the directories with a directory.


Use the File::directories() method.

$list = File::directories('/test');
echo "Test contains ", count($list), "directories.";


The method returns an array of strings.

Each string is the full path to the subdirectories of the directory argument.

If the directory used as the argument contains no subdirectories an empty array is returned.

If the directory argument doesn't exist, an InvalidArgumentException will be thrown.

comments powered by Disqus