I need to create a loop through all files in subdirectories. Can you please help me struct my code like this:
$main = "MainDirectory";
loop through sub-directories {
loop through filels in each sub-directory {
do something with each file
}
};
Come on, first try it yourself!
What you'll need:
and of course
foreach
http://php.net/manual/en/function.is-dir.php
http://php.net/manual/en/function.scandir.php
Use RecursiveDirectoryIterator in conjunction with RecursiveIteratorIterator.
Minor modification on what John Marty posted, if we can safely eliminate any items that are named . or ..
You need to add the path to your recursive call.