Skip to content

Instantly share code, notes, and snippets.

@Caffe1neAdd1ct
Last active December 14, 2015 10:37
Show Gist options
  • Save Caffe1neAdd1ct/f2ece3705053b3e2ea4c to your computer and use it in GitHub Desktop.
Save Caffe1neAdd1ct/f2ece3705053b3e2ea4c to your computer and use it in GitHub Desktop.
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