src/Filesystem.php
/**
     * Deletes a directory even if it is not already empty. This resolves the 
     * issue with trying to use unlink on a non-empty dir.
     * @param String $dir - the path to the directory you wish to delete
     * @return void - changes your filesystem
     */
Deletes a directory even if it is not already empty. This resolves the
issue with trying to use unlink on a non-empty dir.
@param String $dir - the path to the directory you wish to delete
@return void - changes your filesystem
Deletes a directory even if it is not already empty . This resolves the issue with trying to use unlink on a non - empty dir . @param String $dir - the path to the directory you wish to delete @return void - changes your filesystem
public static function deleteDir($dir) 
    {
        if (is_dir($dir)) 
        {
            $objects = scandir($dir);
            foreach ($objects as $object) 
            {
                if ($object != "." && $object != "..") 
                {
                    if (filetype($dir . "/" . $object) == "dir")
                    {
                        self::deleteDir($dir . "/" . $object); 
                    }
                    else
                    {
                        unlink($dir . "/" . $object);
                    }
                }
            }
            reset($objects);
            rmdir($dir);
        }
    }
public static function deleteDir ( $ dir ) { if ( is_dir ( $ dir ) ) { $ objects = scandir ( $ dir ) ; foreach ( $ objects as $ object ) { if ( $ object != " . " && $ object != " .. " ) { if ( filetype ( $ dir . " / " . $ object ) == " dir " ) { self :: deleteDir ( $ dir . " / " . $ object ) ; } else { unlink ( $ dir . " / " . $ object ) ; } } } reset ( $ objects ) ; rmdir ( $ dir ) ; } }
Deletes a directory even if it is not already empty.
Deletes a directory even if it is not already empty .