Page 1 of 1

get a list of files in a directory

Posted: Thu Aug 07, 2003 8:32 pm
by psychotomus
how can i get a list of files in a directory?

Posted: Thu Aug 07, 2003 8:53 pm
by Kriek
Using readdir()

Code: Select all

<?php
    if ($handle = opendir('.')) {
        while (false  !== ($file = readdir($handle))) {
            if ($file  != "." && $file  != "..") {
                echo "$file\n";
            }
        }
        closedir($handle);
    }
?>

Posted: Thu Aug 07, 2003 9:32 pm
by psychotomus
thnx

Posted: Fri Aug 08, 2003 7:24 pm
by Kriek
No problem, glad I could be of assistance to you ;)