How can the compression level be controlled when creating ZIP files in PHP for collecting data?

To control the compression level when creating ZIP files in PHP, you can use the `setCompressionIndex()` method provided by the `ZipArchive` class. This method allows you to set the compression level for each file added to the ZIP archive individually.

$zip = new ZipArchive();
$zip->open('example.zip', ZipArchive::CREATE);

// Set the compression level for each file added to the ZIP archive
$zip->setCompressionIndex(0, ZipArchive::CM_STORE); // no compression
$zip->setCompressionIndex(1, ZipArchive::CM_DEFAULT); // default compression

// Add files to the ZIP archive
$zip->addFile('file1.txt');
$zip->addFile('file2.txt');

$zip->close();