0

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.

3
  • The RecursiveDirectoryIterator class Commented Jun 25, 2014 at 21:37
  • ./application/controllers/*/*.php Btw. using curly braces and GLOB_BRACE makes no sense in your example. (But it can, again, when you want to find .php files in the specified directory and sub-directories at the same time, then you’d just have to specify the version without /*/ as “alternative”.) Commented Jun 25, 2014 at 21:41
  • There is a fine example using RecursiveIteratorIterator in the manual- so what are you struggling with? Commented Jun 25, 2014 at 21:51

1 Answer 1

1

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";
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.