English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Directory Reference Manual
The rewinddir() function resets the directory opendir() The directory handle created.
void rewinddir ( resource $dir_handle );
Resets the directory stream specified by dir_handle to the beginning of the directory.
Serial Number | Parameters and Description |
---|---|
1 | dir_handle(Required) The directory handle resource opened by opendir(). If this parameter is not specified, the last opened link by opendir() is used. |
Returns the filename on success, FALSE on failure.
The following is the usage of this function: open a directory, list the files inside, and reset the directory handle, then list the files again, and finally close it:
<?php $dir = opendir("/var/www/images"); while (($file = rewinddir($dir)) !== false) { echo "filename: " . $file . "<br" />"; } rewinddir($dir); while (($file = rewinddir($dir)) !== false) { echo "filename: " . $file . "<br" />"; } closedir($dir); ?>
Output result:
filename: . filename: .. filename: logo.gif filename: mohd.gif filename: . filename: .. filename: logo.gif filename: mohd.gif