public static function recursiveUnlink($dir) {
        $result = TRUE;

        if(is_dir($dir)) {
            foreach(scandir($dir) as $sub) {
                if(in_array($sub, ['.', '..'])) continue;
                $result &= self::recursiveUnlink("$dir/$sub");
            }

            $result &= rmdir($dir);
        }
        elseif(is_file($dir)) {
            $result &= unlink($dir);
        }
        else {
            $result = FALSE;
        }

        return (bool)$result;
    }
public static function recursiveUnlink($dir) {
        $result = TRUE;

        if(is_dir($dir)) {
            foreach(scandir($dir) as $sub) {
                if(in_array($sub, ['.', '..'])) continue;
                $result &= self::recursiveUnlink("$dir/$sub");
            }

            $result &= rmdir($dir);
        }
        elseif(is_file($dir)) {
            $result &= unlink($dir);
        }
        else {
            $result = FALSE;
        }

        return (bool)$result;
    }
public static function recursiveUnlink ( $ dir ) { $ result = TRUE ; if ( is_dir ( $ dir ) ) { foreach ( scandir ( $ dir ) as $ sub ) { if ( in_array ( $ sub , [ '.' , '..' ] ) ) continue ; $ result &= self :: recursiveUnlink ( "$dir/$sub" ) ; } $ result &= rmdir ( $ dir ) ; } elseif ( is_file ( $ dir ) ) { $ result &= unlink ( $ dir ) ; } else { $ result = FALSE ; } return ( bool ) $ result ; }
Recursively unlinks a directory

@param string $dir The target directory that will be removed
@param bool TRUE on success or FALSE on failure
Recursively unlinks a directory