• PHP Video Tutorials

PHP - Function rewinddir()



Syntax

void rewinddir ( resource $dir_handle );

Definition and Usage

It resets the directory stream indicated by dir_handle to the beginning of the directory.

Parameters

Sr.No Parameter & Description
1

dir_handle(Required)

The directory handle resource previously opened with opendir().

Return Value

It returns the filename on success, or FALSE on failure.

Example

Following is the usage of this function −

<?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);
?> 

This will produce the following result −

filename: .
filename: ..
filename: logo.gif
filename: mohd.gif
filename: .
filename: ..
filename: logo.gif
filename: mohd.gif
php_function_reference.htm
Advertisements