rewinddir

(PHP 4, PHP 5)

rewinddirRewind directory handle

Description

void rewinddir ([ resource $dir_handle ] )

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

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.

Коментарии

/* Source Code */

<?php
$dir 
"/images/";

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

/* Result */

filename: cat.gif
filename: dog.gif
filename: horse.gif
filename: cat.gif
filename: dog.gif
filename: horse.gif
2018-01-27 23:08:33
http://php5.kiev.ua/manual/ru/function.rewinddir.html
It is crucial to note that rewinddir() does not simply start over at the beginning 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 equivalent to a closedir(), opendir() sequence, but without obtaining a new handle.
2018-06-11 22:59:58
http://php5.kiev.ua/manual/ru/function.rewinddir.html

    Поддержать сайт на родительском проекте КГБ