按字母顺序排序opendir

时间:2012-03-23 17:48:01

标签: php opendir

是否可以将opendir按字母顺序排序?

$user = $fgmembersite->UserFullName();
$handle = opendir("users/$user/");

while (false!==($file = readdir($handle))) {
    if ($file != "." && $file != ".."){
        echo 'some code here';
    }
}

提前致谢!

1 个答案:

答案 0 :(得分:6)

我会改用scandir()

$user = $fgmembersite->UserFullName();
$files = scandir('users/' . $user . '/');
foreach ($files as $file) {
    if ($file != '.' && $file != '..') {
        // Do stuff here
    }
}

正如Blauesocke指出的那样,它已经分类了。