Skip to content

Instantly share code, notes, and snippets.

@Caffe1neAdd1ct
Last active December 14, 2015 10:37
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