public static function excludeFromZip(ZipArchive $zipArchive, $pattern)
    {
        $i = 0;
        $exclusionCount = 0;

        while (($entryName = $zipArchive->getNameIndex($i)) || ($statIndex = $zipArchive->statIndex($i,ZipArchive::FL_UNCHANGED))) {
            if ($entryName) {
                // Not previously removed index.
                if (preg_match($pattern, $entryName) === 1 && $zipArchive->deleteIndex($i)) {
                    $exclusionCount++;
                }
            }

            $i++;
        }

        return $exclusionCount;
    }
public static function excludeFromZip(ZipArchive $zipArchive, $pattern)
    {
        $i = 0;
        $exclusionCount = 0;

        while (($entryName = $zipArchive->getNameIndex($i)) || ($statIndex = $zipArchive->statIndex($i,ZipArchive::FL_UNCHANGED))) {
            if ($entryName) {
                // Not previously removed index.
                if (preg_match($pattern, $entryName) === 1 && $zipArchive->deleteIndex($i)) {
                    $exclusionCount++;
                }
            }

            $i++;
        }

        return $exclusionCount;
    }
public static function excludeFromZip ( ZipArchive $ zipArchive , $ pattern ) { $ i = 0 ; $ exclusionCount = 0 ; while ( ( $ entryName = $ zipArchive -> getNameIndex ( $ i ) ) || ( $ statIndex = $ zipArchive -> statIndex ( $ i , ZipArchive :: FL_UNCHANGED ) ) ) { if ( $ entryName ) { // Not previously removed index. if ( preg_match ( $ pattern , $ entryName ) === 1 && $ zipArchive -> deleteIndex ( $ i ) ) { $ exclusionCount ++ ; } } $ i ++ ; } return $ exclusionCount ; }
Exclude from Zip

Exclude entries matching $pattern from a ZIP Archive.

@param ZipArchive $zipArchive An open ZipArchive object.
@param string $pattern A PCRE pattern.
@return int The amount of excluded entries.
Exclude from Zip