sorting - PHP Scandir Not Automatically in Alphabetical Order? -


tia. remedial php skills, can't figure out why scandir isn't automatically sorting alphabetically. (it nice have folders grouped , sorted alphabetically , files grouped , sorted alphabetically, isn't critical.) missing?

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

as wgd said, must use natcasesort following way:

$files = scandir($dir); natcasesort($files); foreach ($files $file) {     // code } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -