<?php

function del_dir ($dir,$type=true)
{
    $n=0;
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                if ( $file == '.' or $file =='..')
                {
                    continue;
                }
                if (is_file ($dir.$file))
                {
                    unlink($dir.$file);
                    $n++;
                }
                if (is_dir ($dir.$file))
                {
                    del_dir ($dir.$file.'/');
                    if ($type)
                    {
                        $n++;
                        rmdir($dir.$file.'/');
                    }
                }
            }
        }
        closedir($dh);
    }
    return $n;
}

?>

相关文章:

  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-14
猜你喜欢
  • 2022-12-23
  • 2021-12-01
  • 2021-10-16
  • 2021-12-03
  • 2021-09-14
相关资源
相似解决方案