$zip = new ZipArchive(); $zip->open('example.zip'); $zip->deleteName('file.txt'); $zip->close();
$zip = new ZipArchive(); $zip->open('example.zip'); for ($i = 0; $i < $zip->numFiles; $i++) { $filename = $zip->getNameIndex($i); if (strpos($filename, 'folder/') === 0) { $zip->deleteName($filename); } } $zip->close();This example demonstrates how to use `deleteName` with conditional statements to remove all files inside a specific folder (in this case, files starting with `folder/`). `deleteName` is part of the `ZipArchive` class, which is included in the PHP language as a built-in class. No external library is required to use it.