While building the upgrade script for tentacle I knew that the file I was going to work with would be a zip, and would contain many subfolders.
PHP has a function called glob that finds files pathnames matching a pattern.
It works really well but only goes one level deep, using the recursive_glob()
function lets you return a folders file structure.
function recursive_glob($pattern = '</em>', $flags = 0, $path = '')
{
$paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
$files = glob($path . $pattern, $flags);
foreach ($paths as $path) {
$files = array_merge($files, recursive_glob($pattern, $flags, $path));
}
return $files;
}