PHP: readdir() function
Description
The readdir() function is used to read an entry from a directory handle opened by opendir() function.
Version:
(PHP 4 and above)
Syntax:
readdir(dir_handle)
Parameter:
Name | Description | Required / Optional |
Type |
---|---|---|---|
dir_handle | Specified directory handle, previously open by opendir(). | Required | Resource. |
Return value:
The filename on success, or FALSE on failure.
Value Type: String.
Example:
<?php
$dir_name = opendir("test");
while (($file = readdir($dir_name)) !== false)
{
echo "filename: " . $file . "<br />";
}
closedir($dir_name)
?>
View the example in the browser
See also
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/php/function-reference/readdir.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics