PHP opendir() Function

The opendir() function opens a directory handle.

resource opendir ( string $path [, resource $context ] )

Opens up a directory handle to be used in subsequent closedir(), readdir(), and rewinddir() calls.

Example -

Result -

The above example will output something similar to:

filename: . : filetype: dir
filename: .. : filetype: dir
filename: apache : filetype: dir
filename: cgi : filetype: dir
filename: cli : filetype: dir

pathRequired. Specifies the directory path to be opened
contextOptional. Specifies the context of the directory handle. Context is a set of options that can modify the behavior of a stream