PHP count total files in directory AND subdirectory function

后端 未结 6 558
小蘑菇
小蘑菇 2021-01-18 22:36

I need to get a total count of JPG files within a specified directory, including ALL it\'s subdirectories. No sub-sub directories.

Structure looks like this :

<
6条回答
  •  一向
    一向 (楼主)
    2021-01-18 23:13

    A for each loops could do the trick more quickly ;-)

    As I remember, opendir is derivated from the SplFileObject class which is a RecursiveIterator , Traversable , Iterator , SeekableIterator class, so, you don't need a while loops if you use the SPL standard PHP Library to retrive the whole images count even on subdirectory.

    But, it's been a while that I didn't used PHP so I might made a mistake.

提交回复
热议问题