public static function renameInZip(ZipArchive $zipArchive, $oldname, $newname)
    {
        $i = 0;
        $renameCount = 0;

        while (($entryName = $zipArchive->getNameIndex($i)) || ($statIndex = $zipArchive->statIndex($i,ZipArchive::FL_UNCHANGED))) {
            if ($entryName) {
                $newEntryName = str_replace($oldname, $newname, $entryName);
                if ($zipArchive->renameIndex($i, $newEntryName)) {
                    $renameCount++;
                }
            }

            $i++;
        }

        return $renameCount;
    }
public static function renameInZip(ZipArchive $zipArchive, $oldname, $newname)
    {
        $i = 0;
        $renameCount = 0;

        while (($entryName = $zipArchive->getNameIndex($i)) || ($statIndex = $zipArchive->statIndex($i,ZipArchive::FL_UNCHANGED))) {
            if ($entryName) {
                $newEntryName = str_replace($oldname, $newname, $entryName);
                if ($zipArchive->renameIndex($i, $newEntryName)) {
                    $renameCount++;
                }
            }

            $i++;
        }

        return $renameCount;
    }
public static function renameInZip ( ZipArchive $ zipArchive , $ oldname , $ newname ) { $ i = 0 ; $ renameCount = 0 ; while ( ( $ entryName = $ zipArchive -> getNameIndex ( $ i ) ) || ( $ statIndex = $ zipArchive -> statIndex ( $ i , ZipArchive :: FL_UNCHANGED ) ) ) { if ( $ entryName ) { $ newEntryName = str_replace ( $ oldname , $ newname , $ entryName ) ; if ( $ zipArchive -> renameIndex ( $ i , $ newEntryName ) ) { $ renameCount ++ ; } } $ i ++ ; } return $ renameCount ; }
Rename in Zip

Rename an item in a ZIP archive. Works for files and directories.

In case of renaming directories, the return value of this method will be the amount of files
affected by the directory renaming.

@param ZipArchive $zipArchive An open ZipArchive object.
@param string $oldname
@param string $newname
@return int The amount of renamed entries.
Rename in Zip