The PHP Function Opendir
The PHP programming language has a set of functions that let you work with files and directories in your web page. The opendir() function opens a directory path, returning a handle to it that you can use with other functions such as readdir() or rewinddir().
The readdir() function takes a handle to the opened directory and returns the name of the next file or directory inside it. This can be used with a while loop to iterate over the directory entries and print them out. The names are returned in the order in which they are stored in the directory (reversed alphabetical order). Unlike glob(), you cannot filter out specific files from the returned array by using this method, but you can still do that with other PHP functions such as scandir() and rmdir().
You can also use the rewinddir() function to step backward through the tree and return an array of names for every entry that is below the current one you are at. This is useful if you have many recursive calls to readdir().
You can also use the mkdir() function to create a new directory at a given path. This is useful if you need to create a new directory for storing some kind of data. You can also use the rmdir() function to delete a directory. It takes the name of a directory as its only parameter. Whenever this function is called, an errno error will be emitted if the specified path is not accessible or if permissions are not allowed for the operation.