readdir

readdir -- read entry from directory handle

Description

string readdir(int dir_handle);

Returns the filename of the next file from the directory. The filenames are not returned in any particular order.

Example 1. List all files in the current directory

<?php
    $handle=opendir('.');
    echo "Directory handle: $handle\n";
    echo "Files:\n";
    while ($file = readdir($handle)) {
        echo "$file\n";
    }
    closedir($handle); 
?>