PHP recursive rmdir


SUBMITTED BY: Guest

DATE: July 12, 2013, 8:34 a.m.

FORMAT: Text only

SIZE: 365 Bytes

HITS: 1116

  1. public function rrmdir($dir) {
  2. if (is_dir($dir)) {
  3. $objects = scandir($dir);
  4. foreach ($objects as $object) {
  5. if ($object != "." && $object != "..") {
  6. if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
  7. }
  8. }
  9. reset($objects);
  10. rmdir($dir);
  11. }
  12. }

comments powered by Disqus