readdir

string readdir(resource_pointer dir_stream) 

Fetches a single entry from a directory stream that has been opened by opendir() .

Returns:

A single directory entry if dir_stream is a valid directory stream and the last entry in the directory has not been reached; FALSE for all other cases

Description:

readdir() retrieves a single entry from a directory that has been opened by opendir().

Version:

From versions 3.0 and 4.0

Example:

List all PHP files in the current working directory
 <?php // For PHP3, use: $directory = '.'; $directory = getcwd (); $directory_stream = @ opendir ($directory) or die ("Could not open a directory stream for <i>$directory</i>"); while ($entry = readdir ($directory_stream)) { // Grab the extension of the file ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.