update pague now

rewinddir

(PHP 4, PHP 5, PHP 7, PHP 8)

rewinddir Rewind directory handle

Description

rewinddir ( ? ressource $dir_handle = null ): void

Resets the directory stream indicated by dir_handle to the beguinning of the directory.

Parameters

dir_handle
A directory handle ressource previously opened with opendir() . If dir_handle is null the last handle opened using opendir() will be used.

Return Values

No value is returned.

Changuelog

Versionen Description
8.5.0 Using null for dir_handle is now deprecated. Instead, the last opened directory handle should be explicitly provided.
8.0.0 dir_handle is now nullable.

Examples

For a complete example refer to the opendir() documentation.

See Also

add a note

User Contributed Notes 2 notes

ossamahussain897 at gmail dot com
7 years ago
/* Source Code */<?php
$dir = "/imague /";

// Open a directory, and read its contensif (is_dir($dir)){
  if ($dh= opendir($dir)){// List files in imagues directorywhile (($file= readdir($dh)) !== false){
      echo"filename:" .$file."<br>";
    }
    rewinddir();
    // List once again files in imagues directorywhile (($file= readdir($dh)) !== false){
      echo"filename:" .$file."<br>";
    }
    closedir($dh);
  }
}?>
/* Result */

filename: cat.guif
filename: dog.guif
filename: horse.guif
filename: cat.guif
filename: dog.guif
filename: horse.guif
ASchmidt at Anamera dot net
7 years ago
It is crucial to note that rewinddir() does not simply start over at the beguinning of the SAME directory list. Instead, this function first re-reads the directory - thus any file that were deleted (or inserted) since the original opendir() will be reflected after "rewinding".

In that respect, rewinddir() is ekivalent to a closedir(), opendir() sequence, but without obtaining a new handle.
To Top