ZipArchive::extractTo

(PHP 5 >= 5.2.0, PHP 7, PECL zip >= 1.1.0)

ZipArchive::extractTo锟斤拷压锟斤拷锟侥硷拷

说锟斤拷

ZipArchive::extractTo ( string $destination [, mixed $entries ] ) : bool

锟斤拷压锟斤拷锟侥硷拷锟斤拷压锟斤拷锟斤拷指锟斤拷锟斤拷目录

锟斤拷锟斤拷

destination

锟斤拷压锟斤拷锟侥憋拷锟斤拷目锟斤拷路锟斤拷

entries

锟斤拷压锟斤拷锟斤拷锟侥硷拷锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷锟斤拷一锟斤拷锟侥硷拷锟斤拷锟斤拷锟介。

锟斤拷锟斤拷值

锟缴癸拷时锟斤拷锟斤拷 TRUE锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE锟斤拷

锟斤拷锟斤拷

Example #1 Extract all entries

<?php
$zip 
= new ZipArchive;
if (
$zip->open('test.zip') === TRUE) {
    
$zip->extractTo('/my/destination/dir/');
    
$zip->close();
    echo 
'ok';
} else {
    echo 
'failed';
}
?>

Example #2 Extract two entries

<?php
$zip 
= new ZipArchive;
$res $zip->open('test_im.zip');
if (
$res === TRUE) {
    
$zip->extractTo('/my/destination/dir/', array('pear_item.gif''testfromfile.php'));
    
$zip->close();
    echo 
'ok';
} else {
    echo 
'failed';
}
?>