[function php] delete all file, folder, subfolder

Table of Contents

Đây là hàm xóa tất tần tật file, thư mục, thư mục con trong folder đó

function rrmdir($dir) {
  if (is_dir($dir)) {
    $objects = scandir($dir);
    foreach ($objects as $object) {
      if ($object != "." && $object != "..") {
        if (filetype($dir."/".$object) == "dir")
           rrmdir($dir."/".$object);
        else unlink   ($dir."/".$object);
      }
    }
    reset($objects);
    rmdir($dir);
  }
 }
Nguồn: stackoverflow -soiqualang_chentreu]]>

Leave a Reply

Your email address will not be published. Required fields are marked *