$allsubdirs = array();
function getAllSubDir($dirs) {
if (is_string($dirs)) $dirs = array($dirs);
global $allsubdirs;
foreach ($dirs as $dir) {
$cwd = getcwd();
chdir($dir) or die("
$dir
");
$files = scandir(".");
foreach ($files as $file) {
if (is_dir($file) && $file != "." && $file != "..") {
$allsubdirs[] = $file;
$full = realpath($file);
echo $full . "
";
getAllSubDir($full);
}
}
chdir($cwd);
}
}
getAllSubDir(array("/var/www/user/6", "/var/www/user/2"));
//output
/var/www/user/6/adsad
/var/www/user/6/asdasd
/var/www/user/6/huyaa
/var/www/user/6/huypv
/var/www/user/6/huypv/newdir
/var/www/user/6/newdir
/var/www/user/6/newdirad
/var/www/user/6/newdirssssssssssss ?DS
/var/www/user/6/nádd
/var/www/user/6/thumuc 1
/var/www/user/6/thumuc 1/thumuc 1-1_1
/var/www/user/6/thumuc 1/thumuc 1-1_1/newdir
/var/www/user/6/thumuc 1/thumuc 1-1_1/newdir/newdir
/var/www/user/6/thumuc 1/thumuc 1-1_1/newdir/newdir/newdir
/var/www/user/6/thumuc 1/thumuc 1-1_1/newdir/newdir/newdir/newdir
/var/www/user/6/zasxas...adasd
/var/www/user/6/zzz
/var/www/user/2/newdir
/var/www/user/2/newdir6
/var/www/user/2/newdir6/newdir7
/var/www/user/2/newdir6/newdirj
/var/www/user/2/newdir6/newdirjj
/var/www/user/2/newdir6/newdiru
/var/www/user/2/newdir6/newdiruy
Title:
get all subdirs in some root dirs
Description:
$allsubdirs = array(); function getAllSubDir($dirs) { if (is_string($dirs)) $dirs = array($dirs); global $allsubdirs; foreach ($dirs as $...
...
Rating:
4