Why does isDot() fail on me? (PHP)

后端 未结 2 467
夕颜
夕颜 2021-02-13 03:25

I\'m finalizing a code segment that lists the files in a directory. I have no problems listing the files in a directory but for some reason I can get the isDot() method to work

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-13 03:40

    The other answer is excellent, but for a different approach you can set the SKIP_DOTS flag:

    setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
    $o_iter = new RecursiveIteratorIterator($o_dir);
    
    foreach ($o_iter as $o_info) {
       echo $o_info->getPathname(), "\n";
    }
    

    https://php.net/filesystemiterator.setflags

提交回复
热议问题