I have the large log files to compress. So, I am using w9 mode for compressing the file.
$contents = "Containing some logs and its some big size. So, using w9 mode";
$fname = "test.gz";
$fp = gzopen($fname, "w9"); // Creating gz file.
gzwrite($fp, $contents); // Writing to file.
gzclose($fp); // Closing file.
The file is getting compressed and saving in the appropriate location properly. Now, from a different file, I am trying to read the contents and display. I want to read it in array format. So, I am using gzfile
function.
if(file_exists($fname)) {
$lines = gzfile($fname, 1);
foreach($lines as $fe_key => $fe_line) {
$lines[$fe_key] = htmlspecialchars($fe_line);
}
print_r($lines);
}
Now, the print_r($lines)
is giving me an empty array.
Please help me, how to fix this problem.
Ask me if I need to elaborate a bit more.
Thanks
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…