HomeMenu
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 . PHP_EOL;
    }

    rewinddir();

    while(($return = readdir()) !== false)
    {
        echo $return . PHP_EOL;
    }

    closedir();
}
127.0.0.1
.
..
index.php
my.sock
127.0.0.1
.
..
index.php
my.sock

2 · dir_handle

<?

$directory = ".";

if($dir_handle = opendir($directory))
{
    while(($return = readdir($dir_handle)) !== false)
    {
        echo $return . PHP_EOL;
    }

    rewinddir($dir_handle);

    while(($return = readdir($dir_handle)) !== false)
    {
        echo $return . PHP_EOL;
    }

    closedir($dir_handle);
}
127.0.0.1
.
..
index.php
my.sock
127.0.0.1
.
..
index.php
my.sock