PHP scandir() လုပ်ဆောင်ချက်
ဥပမာ
ပုံများလမ်းညွှန်အတွင်း၌ ဖိုင်များနှင့် လမ်းညွှန်များကို စာရင်းပြုစုပါ-
<?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() function သည် သတ်မှတ်ထားသော directory ၏ array နှင့် directory များကို ပြန်ပေးသည်။
အထားအသို
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 |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | အောင်မြင်မှုဆိုင်ရာ ဖိုင်များနှင့် လမ်းညွှန်များ၊ အမှားအယွင်းများ လမ်းညွှန်သည် လမ်းညွှန်မဟုတ်ပါက E_WARNING တစ်ခုအား လွှင့်ပစ်ပါ။ |
---|---|
PHP ဗားရှင်း- | 5.0+ |
PHP Changelog- | PHP 5.4- အမှာစာ ကိန်း သေများကို ထည့်ထားသည် ။ |
❮ PHP လမ်းညွှန်အကိုးအကား