وظيفة PHP readdir ()
مثال
أدرج جميع الإدخالات في دليل الصور ، ثم أغلق:
<?php
$dir = "/images/";
// Open a directory, and read its contents
if (is_dir($dir)){
if ($dh = opendir($dir)){
while (($file = readdir($dh)) !== false){
echo "filename:" . $file . "<br>";
}
closedir($dh);
}
}
?>
نتيجة:
filename: cat.gif
filename: dog.gif
filename: horse.gif
التعريف والاستخدام
ترجع الدالة readdir () اسم الإدخال التالي في الدليل.
بناء الجملة
readdir(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 |
تفاصيل تقنية
قيمة الإرجاع: | اسم الإدخال (اسم الملف) عند النجاح ، FALSE عند الفشل |
---|---|
إصدار PHP: | 4.0+ |
❮ مرجع دليل PHP