rewinddir

Rewind directory handle

Syntax

rewinddir(?resource $dir_handle = null): void

Parameters

dir_handle

The directory handle resource previously opened with opendir(). If the directory handle is not specified, the last link opened by opendir() is assumed.

Return

No value is returned.

Examples

1 · void

<?

$directory = ".";

if(opendir($directory))
{
    while(($return = readdir()) !== false)
    {
        echo "$return\n";
    }
    rewinddir();
    while(($return = readdir()) !== false)
    {
        echo "$return\n";
    }
    closedir();
}

?>
index.php
..
.
index.php
..
.

2 · dir_handle

<?

$directory = ".";

if($dir_handle = opendir($directory))
{
    while(($return = readdir($dir_handle)) !== false)
    {
        echo "$return\n";
    }
    rewinddir($dir_handle);
    while(($return = readdir($dir_handle)) !== false)
    {
        echo "$return\n";
    }
    closedir($dir_handle);
}

?>
index.php
..
.
index.php
..
.

chdir

chroot

closedir

dir

getcwd

opendir

readdir

scandir

PHP

Home Menu