Reputation: 7443
I have a content
folder which is full of other sub-directories named in the following way:
id1_1
id1_2
id1_3
id2_1
id2_2
And so on. Each of these folders contains a file template.php
.
The number of folders is dynamic, so I need to find a way to import all the template.php
from all folders starting with id_1_
into my index.php
file. Is there any easy way to do this?
Upvotes: 0
Views: 92
Reputation: 6254
You can use the glob() function:
$arrFiles = glob('./id_1_*/template.php');
foreach($arrFiles as $file) {
include_once($file);
}
Upvotes: 3