PHP rewinddir() 함수
예시
디렉토리를 열고, 파일을 나열하고, 디렉토리 핸들을 재설정하고, 파일을 다시 한 번 나열한 다음 닫습니다.
<?php
$dir = "/images/";
// Open a directory, and read its contents
if (is_dir($dir)){
if ($dh = opendir($dir)){
// List files in images directory
while (($file = readdir($dh)) !== false){
echo "filename:" . $file . "<br>";
}
rewinddir();
// List once again files in images directory
while (($file = readdir($dh)) !== false){
echo "filename:" . $file . "<br>";
}
closedir($dh);
}
}
?>
결과:
filename: cat.gif
filename: dog.gif
filename: horse.gif
filename: cat.gif
filename: dog.gif
filename: horse.gif
정의 및 사용
rewinddir() 함수는 opendir() 에 의해 생성된 디렉토리 핸들을 재설정합니다 .
통사론
rewinddir(dir)
매개변수 값
Parameter | Description |
---|---|
dir | Optional. Specifies the directory handle resource previously opened with opendir(). If this parameter is not specified, the last link opened by opendir() is assumed |
기술적 세부 사항
반환 값: | 성공하면 NULL, 실패하면 FALSE |
---|---|
PHP 버전: | 4.0+ |
❮ PHP 디렉토리 참조