I have the following directory structure:
MainFolder
Folder1
Folder1-1
Folder1-1-1
Folder1-1-2
Folder1-1-3
Folder1-2
Folder1-2-1
Folder1-2-2
Folder1-2-3
Folder2
Folder2-1
Folder2-1-1
Folder2-1-2
Folder2-1-3
Folder2-2
Folder2-2-1
Folder2-2-2
Folder2-2-3
I'm trying to create 3 arrays
1 - array of all subfolders of MainFolder (Folder1, Folder2..etc)
2 - array of subfolders inside of Folder1, Folder2, etc (e.g:Folder1-1...folder2-1...)
3 - array of subfolders inside Folder1-1..., Folder1-2..., etc
this way I can only filter the subdirectories of the current directory:
//path to directory to scan
$directory = "MainFolder/";
//get all files in specified directory
$files = glob($directory . "*");
//print each file name
foreach($files as $file)
{
//check to see if the file is a folder/directory
if(is_dir($file))
{
echo $file;
}
}
but how do I, for glob to filter the current directory and automatically group into array as I showed in the example?
I already saw that RecursiveDirectoryIterator
exists but I did not understand how to put it in different arrays