I’ve been trying to do this for a few days and really I’m struggling. How do I generate all possible scanned folders from the string below and replace all possible folders in %%%ANY_DIR%%%?
$multiple_folder_scan_structure = "Customers/%%%ANY_DIR%%%/HW/%%%ANY_DIR%%%/XR7 and XR7 plus (7702 and 7703)";
The expected output should list all possible complete folder paths found within the defined structure above. With one %%%ANY_DIR%%% this is easy, but with 2 or 3, I’m completely lost as to how to accomplish this.
An example of the expected array would like something like this:
../../Customers/Morrisons/HW/SS90 Card Only (7709)/XR7 and XR7 plus (7702 and 7703)
../../Customers/Morrisons/HW/Test/XR7 and XR7 plus (7702 and 7703)
../../Customers/Sainsbury's/HW/SS90 Card Only (7709)/XR7 and XR7 plus (7702 and 7703)
../../Customers/Tesco/HW/SS90 Card Only (7709)/XR7 and XR7 plus (7702 and 7703)
I have tried to below among other codes, but it clashes as soon as I scan the first %%%ANY_DIR%%%, then the variable I use suddenly isn’t linear. I feel I should implement a dynamic loop (maybe While), but I’m clueless.
I use my “scan_dir_sorted” function here that scans any folder and puts it into an array.
$multiple_folder_scan_structure_anydir_exp = explode('/', $multiple_folder_scan_structure);
$any_dir_counter = 0;
foreach ($multiple_folder_scan_structure_anydir_exp as $folder) {
if (strtoupper($folder) == "%%%ANY_DIR%%%") {
//echo $multiple_folder . "<br>";
foreach (scan_dir_sorted($multiple_folder) as $any_dir) {
//echo $multiple_folder . $any_dir . "<br>";
$any_dir_scanned_folders[$any_dir_counter][] = $any_dir;
}
$any_dir_counter++;
$multiple_folder .= $folder . "/";
}
else
$multiple_folder .= $folder . "/";
}
Any help is appreciated.
Thanks