Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP rewinddir() Function

PHP rewinddir() Function

PHP Directory PHP Directory Reference Manual

Example

Open a directory, list its files, reset the directory handle, list the files again, and then close it:

" ; } rewinddir ( ) ; // list the files in the images directory again while ( ( $file = readdir ( $dh ) ) !== false ) { echo " filename: " . $file . "
" ; } closedir ( $dh ) ; } } ?>

Result:

filename: cat.gif

filename: dog.gif

filename: horse.gif

filename: cat.gif

filename: dog.gif

filename: horse.gif


Definition and Usage

The rewinddir() function resets a directory handle created by opendir() .


Syntax

rewinddir(

dir_handle

);

Parameters Description
dir_handle Optional. Specifies a directory handle resource previously opened by opendir() If this parameter is not specified, the last link opened by opendir() is used.

Technical Details

Return Value: -
PHP Version: 4.0+

PHP Directory PHP Directory Reference Manual