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

后端 未结 7 859
终归单人心
终归单人心 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 18:01

    I'd recommend moving away from the old opendir()/readdir(). Either use glob() or if you encounter a lot of files in a directory then use the DirectoryIterator Class(es):

    http://www.php.net/manual/en/class.directoryiterator.php http://www.php.net/manual/en/function.glob.php

    Regards

    0 讨论(0)
提交回复
热议问题