rewinddir

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

rewinddirСбросить дескриптор каталога

Описание

rewinddir(?resource $dir_handle = null): void

Сбрасывает поток каталога, переданный в параметре dir_handle таким образом, чтобы тот указывал на начало каталога.

Список параметров

dir_handle

Ресурс (resource) дескриптора каталога, ранее открытый с помощью функции opendir(). Если дескриптор каталога не указан, подразумевается последний дескриптор, который был открыт с помощью opendir().

Возвращаемые значения

Функция не возвращает значения после выполнения.

Список изменений

Версия Описание
8.0.0 dir_handle теперь допускает значение null.
Добавить

Примечания пользователей 2 notes

up
6
ASchmidt at Anamera dot net
7 years ago
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.
up
6
osamahussain897 at gmail dot com
7 years ago
/* Source Code */<?php$dir = "/images/";// Open a directory, and read its contentsif (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.giffilename: dog.giffilename: horse.giffilename: cat.giffilename: dog.giffilename: horse.gif
To Top