How can I list all files in a directory sorted alphabetically using PHP?

后端 未结 7 860
终归单人心
终归单人心 2021-01-01 17:01

I\'m using the following PHP code to list all files and folders under the current directory:



        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 17:57

    You could put all the directory names inside an array like:

    $array[] = $file; 
    

    After that you can sort the array with:

    sort($array); 
    

    And then print the links with that content.

    I hope this help.

提交回复
热议问题