PHP: scandir() is too slow

后端 未结 2 590
礼貌的吻别
礼貌的吻别 2020-12-05 21:41

I have to make a function that lists all subfolders into a folder. I have a no-file filter, but the function uses scandir() for listing. That makes the application very slow

2条回答
  •  佛祖请我去吃肉
    2020-12-05 21:59

    Don't write your own. PHP has a Recursive Directory Iterator built specifically for this:

    http://php.net/manual/en/class.recursivedirectoryiterator.php

    As a rule of thumb (aka not 100% of the time), since it's implemented in straight C, anything you build in PHP is going to be slower.

提交回复
热议问题