doukao8851
doukao8851
2015-05-31 15:07

如何递归捕获任何文件[关闭]

已采纳

The following code catches all files recursively in the php extension.

$paths = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($realPath), \RecursiveIteratorIterator::SELF_FIRST);
$files = new \RegexIterator($paths, '/\.(?:php)$/', \RegexIterator::MATCH);

foreach($files as $file){
    ...

I want to get files from any extension. I want something to replace it: '/\.(?:php)$/'

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • doulin2947 doulin2947 6年前

    Wouldn't you just change

      /\.(?:php)$/
    

    to

     /.*/
    
    点赞 评论 复制链接分享