php rewinddir() function


  Translation results:

UK[ˌri:ˈwaɪnd] US[riˈwaɪnd]

v. Rewind; rewind (video, audio tape, etc.)

n. Rewind; rewinder

Third person singular: rewinds Plural: rewinds Present participle: rewinding Past tense: rewound Past participle: rewound

php rewinddir() functionsyntax

Function: Reset the directory handle created by opendir().

Syntax: rewinddir(dir_handle)

Parameters:

Parameter 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.

Description: Reset the directory handle created by opendir().

php rewinddir() functionexample

<?php
$dir = "/phpstudy/WWW/20180414/";
// 打开目录,然后读取其内容
if ($dh = opendir($dir)){
        while (($file = readdir($dh)) !== false)
        {
            echo "filename:" . $file . "<br>";
        }
        //重置目录句柄
        rewinddir();
        while (($file = readdir($dh)) !== false)
        {
            echo "filename:" . $file . "<br>";
        }
}
?>

Home

Videos

Q&A