TechniqueUse the maptree() method in PEAR's File_Find class: <?php include_once 'File/Find.php'; list ($directories, $files) = File_Find::maptree('/www/htdocs'); ?> CommentsTo load an entire directory tree into an array, we use PEAR's File_Find class. The File_Find class provides many useful methods for loading and searching directory trees. The maptree() method will return an array containing two arrays: The first array is a list of all the directories in the specified directory, and the second is a list of all the files in all the directories. If you want to load only the current directory, use the mapdir() method. It has the same syntax as the maptree() method, except that it returns an array of all the file and directory names in the specified directory: <?php include_once 'File/Find.php'; $fsystem = File_Find::mapdir ('/www/htdocs'); foreach ($fsystem as $ent) { print "$ent\n"; } ?> |