Posted By

spcmnk on 10/07/11


Tagged

php file delete recursive


Versions (?)

Delete directory and its content recursively


 / Published in: PHP
 

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

Report this snippet  

You need to login to post a comment.