当前位置:Gxlcms > PHP教程 > php解压rar文件php打包zip文件源码php_rar.dllpclzip示例

php解压rar文件php打包zip文件源码php_rar.dllpclzip示例

时间:2021-07-01 10:21:17 帮助过:2人阅读

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解压rar文件 php打包zip文件 源码php_rar.dll pclzip示例

人气教程排行