How to get information from a file inside a ZIP? (PHP)

  PHP Scripts

We have built a function easy to use on any project. Example how to use on the end of the code.

<?php

// Parameters avvailable for $inf: 
// name, index, crc, size, mtime, comp_size, comp_method
// $zipindex is the index from the file inside the zip

function GetZipInfo($file, $zipindex, $inf)
{
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
$info = ($zip->statIndex($zipindex));
$zip->close();
return $info[$inf];
} else {
return 'Error:' . $res;
}
}

echo GetZipInfo('folder/file.zip', 0 ,'name');
echo GetZipInfo('folder/file.zip', 0 ,'crc');

?>