PHP readdir() Function
Complete PHP Directory Reference
Definition and Usage
The readdir() function returns an entry from a directory handle opened by
opendir().
This function returns a filename on success and FALSE on
failure.
Syntax
Parameter |
Description |
dir_stream |
Required. Specifies the directory handle to use |
Example
<?php
//Open images directory
$dir = opendir("images");
//List files in images directory
while (($file = readdir($dir)) !== false)
{
echo "filename: " . $file . "<br />";
}
closedir($dir);
?>
|
The output of the code above could be:
filename: .
filename: ..
filename: cat.gif
filename: dog.gif
filename: food
filename: horse.gif
|
Complete PHP Directory Reference
|
|
|
See why there are 20,000+ Ektron integrations worldwide.
Request an INSTANT DEMO or download a FREE TRIAL today. |
|
|
|