小编WGD*_*WGD的帖子

PHP Scandir 不是按字母顺序自动排列的?

TIA。凭借我的 PHP 补救技能,我无法弄清楚为什么 scandir 不能按字母顺序自动排序。(将文件夹组合在一起并按字母顺序排序以及将文件组合在一起并按字母顺序排序也很好,但这并不重要。)我错过了什么?

<?php
$dir = './customers/' . $customer . "/";
$exclude = array(".","..",".htaccess");
    if (is_dir($dir)) {
        $files = scandir($dir);
        foreach($files as $key=>$dir){
            if(!in_array($dir, $exclude)){
    echo ("<a href=\"./customers/$customer/".$dir."\">".$dir."</a><br>");
        }
    }
}
?>
Run Code Online (Sandbox Code Playgroud)

php sorting scandir

4
推荐指数
1
解决办法
2034
查看次数

标签 统计

php ×1

scandir ×1

sorting ×1