Listing certain filetypes of multiple directories in PHP

thini

New Member
I really do not have much PHP knowledge, and what I am trying to build is essentially a much cleaner default apache directory listing with PHP. I have managed to almost achieve what I want by searching here and other tutorials, however I am now slightly stuck.I would like to have the script search all directories and subdirectories for files with the filetype .htmlThe way the list is organized with directories and subdirectories being indented lists is preferable. This is done with this code:\[code\]<?phpfunction listFolderFiles($dir,$exclude){ $ffs = scandir($dir); echo '<ul class="ulli">'; foreach($ffs as $ff){ if(is_array($exclude) and !in_array($ff,$exclude)){ if($ff != '.' && $ff != '..' ){ if(!is_dir($dir.'/'.$ff)){ echo '<li><a href="http://stackoverflow.com/questions/15825303/edit_page.php?path='.ltrim($dir.'/'.$ff,'./').'">'.$ff.'</a>'; } else { echo '<li>'.$ff; } if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff,$exclude); echo '</li>'; } } } echo '</ul>';}listFolderFiles('.',array('index.php','edit_page.php'));?>\[/code\]Now I thought that changing the 7th line to this would work but it doesn't and limits the search to only the root directory:\[code\] if($ff != '.' && $ff != '..' && strtolower(substr($ff, strrpos($ff, '.') + 1)) == 'html')\[/code\]I would greatly appreciate it if someone could tell me what I am doing wrong.
 
Back
Top