PHP » I/O » readdir()

Syntax:
string readdir(int dh)
dh
A directory handle.

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.

Examples

Code:
<?php

$dh = opendir("upload");

while ($file = readdir($dh)) {
   print "$file ";
if (!is_dir($file))
   print "(file)";
else
   print "(directory)";
print "<br>";
}

?>
Output:
. (directory)
.. (directory)
code.php (file)
test.txt (file)
Explanation:

The contents of the upload directory are listed.

See Also: