×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: ActionScript
Posted by: Bob Ray
Added: Jul 27, 2015 6:14 PM
Views: 3
Recursively remove directory and all it's children
  1. /** recursive remove dir function */
  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") {
  8.                     $this->rrmdir($dir . "/" . $object);
  9.                 } else {
  10.                     unlink($dir . "/" . $object);
  11.                 }
  12.             }
  13.         }
  14.         reset($objects);
  15.         rmdir($dir);
  16.     }
  17. }