Rodrigo Vieira
Rodrigo Vieira

Reputation: 311

How to catch any file recursively

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)$/'

Upvotes: 0

Views: 52

Answers (1)

Garrett R. Davis
Garrett R. Davis

Reputation: 339

Wouldn't you just change

  /\.(?:php)$/

to

 /.*/

Upvotes: 0

Related Questions