What are the potential limitations of using PHP to unpack zip files, especially in terms of client-side operations?

When using PHP to unpack zip files, one potential limitation is the amount of memory required to extract large zip files. This can lead to memory exhaustion errors, especially when dealing with files that are several gigabytes in size. To address this issue, you can use the ZipArchive class in PHP, which allows you to extract files one by one rather than all at once, thus reducing the memory usage.

$zip = new ZipArchive;
$res = $zip->open('file.zip');
if ($res === TRUE) {
    for ($i = 0; $i < $zip->numFiles; $i++) {
        $filename = $zip->getNameIndex($i);
        $zip->extractTo('extracted_files/', $filename);
    }
    $zip->close();
} else {
    echo 'Failed to open zip file';
}