PHP readdir() Function
PHP Directory Reference Manual
Example
Open a directory, read its contents, and then close it:
"; } closedir($dh); } } ?>Result:
filename: cat.gif
filename: dog.gif
filename: horse.gif
Definition and Usage
The readdir() function returns the file name of the next file in a directory.
Syntax
readdir(
dir_handle
);
| Parameters | Description |
|---|---|
| dir_handle | Optional. Specifies a directory handle resource previously opened by opendir() If this parameter is not specified, the last link opened by opendir() is used. |
Technical Details
| Return Value: | Returns the file name on success, or FALSE on failure. |
|---|---|
| PHP Version: | 4.0+ |
PHP Directory Reference Manual