Returns the next directory entry.
readdir() returns the next entry in the directory of the specified directory handle. If no more entries are available FALSE is returned.
<?php
$dh = opendir("upload");
while ($file = readdir($dh)) {
print "$file ";
if (!is_dir($file))
print "(file)";
else
print "(directory)";
print "<br>";
}
?> . (directory)
.. (directory)
code.php (file)
test.txt (file) The contents of the upload directory are listed.