Friday, January 20, 2012

PHP Code to remove directory & its files

<?php

function rrmdir($dir) {
  if (is_dir($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);
  }
}


?>

No comments:

Post a Comment