PHP rewinddir() Function

PHP rewinddir Function


Definition :

In php  rewinddir() Function is inbuilt function.The rewinddir() function is used to rewind the directory handle. The rewinddir() function opens a directory and list its files, resets the directory handle, list its files once again, then finally closes the directory handle.

Syntax

  rewinddir(dir)

Parameter
Parameter Description
dir Optional. Specifies the directory handle resource previously opened with opendir(). If this parameter is not specified, the last link opened by opendir() is assumed

Given below example Open a directory, list its files, reset directory handle, list its files once again, then close:

Output :

File Name: .
File Name: ..
File Name: content.xlsx
File Name: gfg.pdf
File Name: image.jpeg
File Name: .
File Name: ..
File Name: content.xlsx
File Name: gfg.pdf
File Name: image.jpeg