标签:txt pat $path unzip fopen cti ace func eof
//解压tar.gz, gz
public function unzip_gz($gz_file){
if(!strpos($gz_file,‘.gz‘)){
return false;
}
$buffer_size = 4096; // read 4kb at a time
if(strpos($gz_file,‘.tar.gz‘)===false) {
$out_file_name = str_replace(‘.gz‘, ‘.txt‘, $gz_file);
}else{
$out_file_name = str_replace(‘.tar.gz‘, ‘‘, $gz_file);
}
$file = gzopen($gz_file, ‘rb‘);
$out_file = fopen($out_file_name, ‘wb‘);
$str=‘‘;
while(!gzeof($file)) {
fwrite($out_file, gzread($file, $buffer_size));
}
fclose($out_file);
gzclose($file);
unlink($gz_file);
return true;
}
$path = "要解压的文件路径";
unzip_gz($path);
标签:txt pat $path unzip fopen cti ace func eof
原文地址:https://www.cnblogs.com/lsbaiwyl/p/9020024.html