Crmgo Блог

PHP, Рекурсивный поиск и удаление пустых папок

PHP, Рекурсивный поиск и удаление пустых папок

# made by Lomaka Dmitriy <?php echo date("h:i:s")." start"; chdir ("/home/"); @browser(); echo date("h:i:s")." stop"; //$all = ""; function browser($dir){ $files=glob("*"); foreach ($files as $file){ if ($file == "." || $file == "..") continue; if (is_dir ($file)){ chdir ($file); $all_dir=getcwd();…

PHP, Рекурсивный поиск и удаление пустых папок

# made by Lomaka Dmitriy

<?php
echo date("h:i:s")." start";
chdir ("/home/");
@browser();
echo date("h:i:s")." stop";
//$all = "";
function browser($dir){
$files=glob("*");
foreach ($files as $file){
if ($file == "." || $file == "..") continue;
if (is_dir ($file)){
chdir ($file);
$all_dir=getcwd();
$is_empty=count(scandir($all_dir));
if ($is_empty<3){
rmdir ($all_dir);
echo $all_dir." ---удален."."\n";
} else {
browser($file);
}
chdir ("..");

}
}
}

?>

Примечание: материал мог быть создан с помощью ИИ и затем отредактирован человеком. Ответственный: Dmytro Lomaka, Kaltenkirchen.

Рубрики: PHP