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);
}
}
?>
$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
filename: dog.gif
filename: horse.gif
filename: cat.gif
filename: dog.gif
filename: horse.gif
정의 및 사용
rewinddir () 함수에 의해 리셋 했던 opendir () 디렉토리 핸들이 생성되었습니다.
문법
rewinddir( dir_handle );
参数 | 描述 |
---|---|
dir_handle | 可选。指定之前由 opendir() 打开的目录句柄资源。如果该参数未指定,则使用最后一个由 opendir() 打开的链接。 |
기술 세부 사항
반환 값 : | - |
---|---|
PHP 버전 : | 4.0 이상 |
PHP 디렉토리 참조