Nightloewe
Nightloewe

Reputation: 1098

Find subdirectory with specific name

For a php application I want to search directories for specific subdirectories where I want to require all files in this directories.

The path would look like so:

/app/*/route/*.php

How can I do this?

Upvotes: 0

Views: 45

Answers (1)

Sahil Gulati
Sahil Gulati

Reputation: 15141

using glob function help you in achieving this.

glob('/app/*/route/*.php');

For requiring all those files can use this

foreach(glob('/app/*/route/*.php') as $file)
{
     require_once $file;
}

Upvotes: 1

Related Questions