在php中对字符串进行压缩的方法
使用gzip压缩算法进行压缩
$data = implode("", file("bigfile.txt"));
$gzdata = gzencode($data, 9);
$fp = fopen("bigfile.txt.gz", "w");
fwrite($fp, $gzdata);
fclose($fp);
使用bzcompress()函数进行压缩
$str = "sample data";
$bzstr = bzcompress($str, 9);
echo $bzstr;
使用gzdeflate()函数进行压缩
$compressed = gzdeflate('Compress me', 9);
echo $compressed;
使用gzcompress()函数进行压缩
$compressed = gzcompress('Compress me', 9);
echo $compressed;