我有一个文件夹,里面有一些文件和子文件夹。我需要返回具有给定扩展名的文件名或相对地址(如果文件在子文件夹中),例如.html
。在目录树中查找给定扩展名的文件
例如,这是给定文件夹的结构:
- /text/something.ncx
- /text/123.html
- content.opf
- toc.ncx
- Flow_0 .html
- Flow_1.html
- Flow_2.html
因此,代码(理想情况下以阵列)返回此:
- 文本/ 123.html
- Flow_0.html
- Flow_1.html
- Flow_2.html
这只是拔出.html
扩展名,但我真的不怎么解决这个问题。
可能的重复:http://stackoverflow.com/questions/3062154/php-list-of-specific-files-in-a-directory – 2012-11-27 23:05:54
可能的重复:http://stackoverflow.com/questions/3226519/use -php-scandirdir-and-get-only-images – 2012-11-27 23:06:37