पीएचपी स्कैंडर () फ़ंक्शन
उदाहरण
छवियों निर्देशिका के अंदर फाइलों और निर्देशिकाओं की सूची बनाएं:
<?php
$dir = "/images/";
// Sort in ascending order - this is default
$a = scandir($dir);
// Sort in descending order
$b = scandir($dir,1);
print_r($a);
print_r($b);
?>
परिणाम:
Array
(
[0] => .
[1] => ..
[2] => cat.gif
[3] => dog.gif
[4] => horse.gif
[5] => myimages
)
Array
(
[0] => myimages
[1] => horse.gif
[2] => dog.gif
[3] => cat.gif
[4] => ..
[5] => .
)
परिभाषा और उपयोग
स्कैंडर () फ़ंक्शन निर्दिष्ट निर्देशिका की फ़ाइलों और निर्देशिकाओं की एक सरणी देता है।
वाक्य - विन्यास
scandir(directory, order, context)
पैरामीटर मान
Parameter | Description |
---|---|
directory | Required. Specifies the directory to be scanned |
order | Optional. Specifies the sorting order. Default sort order is alphabetical in ascending order (0). Set to SCANDIR_SORT_DESCENDING or 1 to sort in alphabetical descending order, or SCANDIR_SORT_NONE to return the result unsorted |
context | Optional. Specifies the context of the directory handle. Context is a set of options that can modify the behavior of a stream |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | सफलता पर फाइलों और निर्देशिकाओं की एक सरणी, विफलता पर FALSE। यदि निर्देशिका निर्देशिका नहीं है तो E_WARNING फेंकता है |
---|---|
पीएचपी संस्करण: | 5.0+ |
पीएचपी चेंजलॉग: | PHP 5.4: ऑर्डर स्थिरांक जोड़े गए थे |
पीएचपी निर्देशिका संदर्भ