RNK
RNK

Reputation: 5792

find php files from directory within directory

I have code for find php files from one directory.

$files = glob('./application/controllers/*.{php}', GLOB_BRACE);

Is there any way to find php files from directory within directory.

I mean, if there are some folders in controllers folder and inside those folders php files are there. then, how can I detect those files too.

Upvotes: 0

Views: 78

Answers (1)

buff
buff

Reputation: 2053

You can use Nette Finder (https://packagist.org/packages/nette/finder) and do

$files = Finder::findFiles('*.php')->from('./application/controllers/');
foreach ($files as $file) {
    echo "$file\n";
}

Upvotes: 1

Related Questions