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 ไดเรกทอรีอ้างอิง