पीएचपी रीडडिर () फंक्शन
उदाहरण
छवि निर्देशिका में सभी प्रविष्टियों को सूचीबद्ध करें, फिर बंद करें:
<?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 |
---|---|
पीएचपी संस्करण: | 4.0+ |
पीएचपी निर्देशिका संदर्भ