w3resource
PHP Tutorial

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

PHP Function Reference



New Content: Composer: Dependency manager for PHP, R Programming