public static function deleteFolder($strPath)
    {

        if (!is_dir($strPath)) {
            unlink($strPath);

            return 1;
        }

        $d = dir($strPath);
        $count = 0;
        while ($entry = $d->read()) {
            if ($entry != "." && $entry != "..") {
                if (is_dir($strPath)) {
                    $count += Folder::deleteFolder($strPath . "/" . $entry);
                }
            }
        }

        $d->close();
        rmdir($strPath);

        return $count;
    }
public static function deleteFolder($strPath)
    {

        if (!is_dir($strPath)) {
            unlink($strPath);

            return 1;
        }

        $d = dir($strPath);
        $count = 0;
        while ($entry = $d->read()) {
            if ($entry != "." && $entry != "..") {
                if (is_dir($strPath)) {
                    $count += Folder::deleteFolder($strPath . "/" . $entry);
                }
            }
        }

        $d->close();
        rmdir($strPath);

        return $count;
    }
public static function deleteFolder ( $ strPath ) { if ( ! is_dir ( $ strPath ) ) { unlink ( $ strPath ) ; return 1 ; } $ d = dir ( $ strPath ) ; $ count = 0 ; while ( $ entry = $ d -> read ( ) ) { if ( $ entry != "." && $ entry != ".." ) { if ( is_dir ( $ strPath ) ) { $ count += Folder :: deleteFolder ( $ strPath . "/" . $ entry ) ; } } } $ d -> close ( ) ; rmdir ( $ strPath ) ; return $ count ; }
Allows for deletion of non-empty directories - takes care of
recursion appropriately.

@param    string $strPath Full path to the folder to be deleted

@return    int    number of deleted files
Allows for deletion of non - empty directories - takes care of recursion appropriately .