library/FileCopier.php
protected function deleteTree($directory, $removeBaseDir = false)
    {
        $files = array_diff(scandir($directory), array('.', '..'));
        foreach ($files as $file) {
            (is_dir("$directory/$file")) ? $this->deleteTree("$directory/$file", true) : @unlink("$directory/$file");
        }

        if ($removeBaseDir) {
            @rmdir($directory);
        }
    }
protected function deleteTree($directory, $removeBaseDir = false)
    {
        $files = array_diff(scandir($directory), array('.', '..'));
        foreach ($files as $file) {
            (is_dir("$directory/$file")) ? $this->deleteTree("$directory/$file", true) : @unlink("$directory/$file");
        }

        if ($removeBaseDir) {
            @rmdir($directory);
        }
    }
protected function deleteTree ( $ directory , $ removeBaseDir = false ) { $ files = array_diff ( scandir ( $ directory ) , array ( '.' , '..' ) ) ; foreach ( $ files as $ file ) { ( is_dir ( "$directory/$file" ) ) ? $ this -> deleteTree ( "$directory/$file" , true ) : @ unlink ( "$directory/$file" ) ; } if ( $ removeBaseDir ) { @ rmdir ( $ directory ) ; } }
Deletes given directory content

@param string $directory       Path to directory.
@param bool   $removeBaseDir Whether to delete base directory.
Deletes given directory content