Php rewinddir
From w3cyberlearnings
Contents |
PHP function rewinddir
This function resets the directory handle created by opendir().
Syntax rewinddir
dir is a directory handle.
rewinddir(dir);
Example 1
?php $path = dirname(__FILE__).'/mydir'; $dh = opendir($path); $count = 0; while(($d = readdir($dh)) !== false) { $pfile = $path. '/'. $d; echo $pfile ."\n"; if($count==3) { rewinddir($dh); } $count++; } closedir($dh); ?>
Output
/home/w3cyberlearnings/testphp/mydir/learn.txt /home/w3cyberlearnings/testphp/mydir/a1 /home/w3cyberlearnings/testphp/mydir/ac /home/w3cyberlearnings/testphp/mydir/a2 /home/w3cyberlearnings/testphp/mydir/learn.txt /home/w3cyberlearnings/testphp/mydir/a1 /home/w3cyberlearnings/testphp/mydir/ac /home/w3cyberlearnings/testphp/mydir/a2 /home/w3cyberlearnings/testphp/mydir/. /home/w3cyberlearnings/testphp/mydir/ab /home/w3cyberlearnings/testphp/mydir/.. /home/w3cyberlearnings/testphp/mydir/school
--chdir-- chroot-- closedir-- dir-- getcwd-- opendir-- readdir-- rewinddir-- scandir--