How to catch any file recursively

60 Views Asked by At

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

There are 1 best solutions below

4
On BEST ANSWER

Wouldn't you just change

  /\.(?:php)$/

to

 /.*/