Return to Snippet

Revision: 10570
at January 5, 2009 06:12 by fruehjahr


Initial Code
function dirList ($directory) {
    // create an array to hold directory list
    $results = array();
 
    // create a handler for the directory
    $handler = opendir($directory);
 
    // keep going until all files in directory have been read
    while ($file = readdir($handler)) {
 
        // if $file isn't this directory or its parent,
        // add it to the results array
        if ($file != '.' && $file != '..')
            $results[] = $file;
    }
 
    // tidy up: close the handler
    closedir($handler);
 
    // done!
    return $results;
}

Initial URL
http://www.laughing-buddha.net/jon/php/dirlist/

Initial Description


Initial Title
List files in directory

Initial Tags
list, files, directory

Initial Language
PHP