PHP » I/O » rewinddir()

Syntax:
void rewinddir(int dh)
dh
A directory handle.

Resets a directory stream.

This function resets the directory pointer so that readdir() returns the first entry again.

Examples

Code:
<?php

$dh = opendir("upload");

$file = readdir($dh);
print "[$file]<br>";
rewinddir($dh);
$file = readdir($dh);
print "[$file]";

?>
Output:
[.]
[.]
Explanation:

Using rewinddir(), the pointer is reset so that the first entry of the directory is read twice.

See Also: