Home  >  Article  >  Backend Development  >  php decompress rar file php package zip file source code php_rar.dll pclzip example

php decompress rar file php package zip file source code php_rar.dll pclzip example

高洛峰
高洛峰Original
2016-11-28 16:45:051360browse

define('ROOT_DIR','D:/web/');
  
$rar = '2012051008.rar';
$rar_name = basename($rar,'.rar');
  
$rar_file = rar_open(ROOT_DIR.$rar) or die("失败");
$entries = rar_list($rar_file);
$arr_name = array();
foreach($entries as $entry){
    $name = $entry->getName();
    if(substr($name,-4) == '.txt') {
        $entry->extract(ROOT_DIR);
        $arr_name[] = $name;
    }  
}
rar_close($rar_file);
  
$arr_name = array('2012051008.txt','说明.txt');
$file = ROOT_DIR.$rar_name.'.zip';
require('./pclzip.lib.php');
$zip = new pclzip($file);
$list = $zip->create($arr_name);
if($list != 0) {
    foreach($arr_name as $key=>$val) {
        unlink(ROOT_DIR.$val);
    }
}

php decompress rar file php package zip file source code php_rar.dll pclzip example


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn