Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Find total uncompressed size of a zip archive
#!/usr/bin/env php
<?php
$zip = new ZipArchive();
if ($zip->open('name.zip') === true) {
var_dump(getTotalUncompressedSize($zip));
$zip->close();
}
function getTotalUncompressedSize(ZipArchive $zip)
{
$totalSize = 0;
for ($i = 0; $i < $zip->numFiles; $i++) {
$fileStats = $zip->statIndex($i);
$totalSize += $fileStats['size'];
}
return $totalSize;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment