Directory functions Directories chdir change directory Description int chdir string directory Changes PHP's current directory to directory. Returns FALSE if unable to change directory, TRUE otherwise. dir directory class Description new dir string directory A pseudo-object oriented mechanism for reading a directory. The given directory is opened. Two properties are available once directory has been opened. The handle property can be used with other directory functions such as readdir, rewinddir and closedir. The path property is set to path the directory that was opened. Three methods are available: read, rewind and close. Dir() Example $d = dir("/etc"); echo "Handle: ".$d->handle."<br>\n"; echo "Path: ".$d->path."<br>\n"; while($entry=$d->read()) { echo $entry."<br>\n"; } $d->close(); closedir close directory handle Description void closedir int dir_handle Closes the directory stream indicated by dir_handle. The stream must have previously been opened by opendir. opendir open directory handle Description int opendir string path Returns a directory handle to be used in subsequent closedir, readdir, and rewinddir calls. 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. 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); ?> rewinddir rewind directory handle Description void rewinddir int dir_handle Resets the directory stream indicated by dir_handle to the beginning of the directory.