Skip to content

Instantly share code, notes, and snippets.

@owzim
Created November 29, 2014 20:15
Show Gist options
  • Select an option

  • Save owzim/94bfe7b8822f1759d986 to your computer and use it in GitHub Desktop.

Select an option

Save owzim/94bfe7b8822f1759d986 to your computer and use it in GitHub Desktop.

Revisions

  1. Christian Raunitschka created this gist Nov 29, 2014.
    12 changes: 12 additions & 0 deletions rm-recursive.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    <?php

    class dir {
    public static function rmRecursive($dir) {
    $files = array_diff(scandir($dir), array('.','..'));
    foreach ($files as $file) {
    is_dir("$dir/$file") ? self::rmdirRecursive("$dir/$file") : unlink("$dir/$file");
    }
    return rmdir($dir);
    }
    }