I want to do a RecursiveDirectoryIterator on a set of folders in a directory, say ./temp and then list the files in each folder according to the name of the fol
//Managed to put this together and it somehow works for me. If you have other options please provide. Thanks
$path='./temp';
$dir = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $file=>$mykey) {
if(is_dir($file)) {
$directory = $file;
$mydir = new RecursiveIteratorIterator(new RecursiveRegexIterator(new RecursiveDirectoryIterator($directory,RecursiveDirectoryIterator::FOLLOW_SYMLINKS),
// match both pdf file extensions and directories
'#(?$mykey) {
$result[] = $myfile.'
';
$filetypes = array("pdf");
$filetype = pathinfo($myfile, PATHINFO_EXTENSION);
if (in_array(strtolower($filetype), $filetypes)) {
// output all matches substr(dirname($file),11)
?>
>
getFilename(), '.pdf') !== FALSE) {?>