php8.5
Home/ Manual/ zip / ziparchive/ ZipArchive::deleteName

ZipArchive::deleteName

PHP function Edit on GitHub ✎

(PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL zip >= 1.5.0)

Delete an entry in the archive using its name

Description

ZipArchive::deleteName(string $name): bool

Delete an entry in the archive using its name.

Parameters

name

Name of the entry to delete.

Return Values

Success

Examples

Deleting a file and directory from an archive, using names

php
<?php
$zip = new ZipArchive;
if ($zip->open('test1.zip') === TRUE) {
    $zip->deleteName('testfromfile.php');
    $zip->deleteName('testDir/');
    $zip->close();
    echo 'ok';
} else {
    echo 'failed';
}
?>

Source: reference/zip/ziparchive/deletename.xml · from the official PHP manual (php/doc-en)