(PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL zip >= 1.5.0)
ZipArchive::deleteName — 使用名稱刪除壓縮檔中的項目
name
要刪除的項目的名稱。
範例 #1 使用名稱從壓縮檔中刪除檔案和目錄
<?php
$zip = new ZipArchive;
if ($zip->open('test1.zip') === TRUE) {
$zip->deleteName('testfromfile.php');
$zip->deleteName('testDir/');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
?>