Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

rewinddir

Description

The rewinddir of Directory for PHP rewinds a 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
my.sock
..
.
127.0.0.1
index.php
my.sock
..
.
127.0.0.1

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
my.sock
..
.
127.0.0.1
index.php
my.sock
..
.
127.0.0.1
HomeMenu