php - list only directories that contain certain files -
the following code below works fine listing directories , excluding don't want in array list, i'd add feature able list directories contain files.
for example: list directories contain files: array('file1.php','file2.php');
$exclude = array('admin','inc'); foreach(glob('./*', glob_onlydir) $dir) { $dir = str_replace('./', '', $dir); if (!in_array($dir, $exclude)) { //list directories } }
$exclude = array('admin','inc'); $required = array('file1.php', 'file2.php'); foreach(glob('./*', glob_onlydir) $dir) { $dir = str_replace('./', '', $dir); if (!in_array($dir, $exclude)) { foreach($required $r) { if (file_exists("$dir/$r")) { echo $dir, "\n"; break; } } } }
Comments
Post a Comment