Method PclZip::delete()
Overview
This method remove from the archive all or part of the files contained in the PKZIP file.Synopsis
PclZip::delete([options list])
Arguments
options list :
This method support the following optional arguments :
- PCLZIP_OPT_BY_NAME
- PCLZIP_OPT_BY_EREG
- PCLZIP_OPT_BY_PREG
- PCLZIP_OPT_BY_INDEX
See chapter "Optional arguments" for more informations.Returned values
0
On error.
an array
The list of the files (and their properties) that are still present in the archive..
(See "Returned values ")Description
This method remove from the archive all or part of the files contained in the PKZIP file.
Filtering can be used to remove only specific files from the archive. Filters are defined by the optional arguments PCLZIP_OPT_BY_NAME, PCLZIP_OPT_BY_EREG, PCLZIP_OPT_BY_PREG and PCLZIP_OPT_BY_INDEX.Sample
require_once('pclzip.lib.php');
$archive = new PclZip('archive.zip');
$v_list = $archive->delete();
if ($v_list == 0) {
die("Error : ".$archive->errorInfo(true));
}
In this sample all the files contained in the archive are removed.
require_once('pclzip.lib.php');
$archive = new PclZip('archive.zip');
$v_list = $archive->delete(PCLZIP_OPT_BY_INDEX, '1-3,5,8-10');
if ($v_list == 0) {
die("Error : ".$archive->errorInfo(true));
}
In this sample, files at index 1 to 3, 5 and 8 to 10 removed from the archive. Files (and folders entries) index can be found be using the listContent() method.
Please notice that a folder has its own entry (with its own index). When removing the folder entry the files belonging to this folder are not removed.require_once('pclzip.lib.php');
$archive = new PclZip('archive.zip');
$v_list = $archive->delete(PCLZIP_OPT_BY_EREG, 'txt$');
if ($v_list == 0) {
die("Error : ".$archive->errorInfo(true));
}In this sample all files finishing by 'txt' are removed from the archive.
| [Back to Methods List] |




