Tom
Tom

Reputation: 1628

PHP open and read xz file

For a plain text file I'm using:

$fh = fopen("log.txt", 'r') or die($php_errormsg);
while (!feof($fh)) {
   $line = fgets( $fh, 4096 );
   echo $line;
}

Is there a similar way to do this with a .xz file ? I've googled and I'm not finding much related to it.

Basically I need to be able to read through a .xz compressed file in the same way I do with a text file.

Thanks

Upvotes: 0

Views: 981

Answers (1)

Clement Sam
Clement Sam

Reputation: 750

You can read the .xz file with popen().

$fname = 'log.xz';
$fh = popen("xz -cd --files0=" . $fname, 'r');

Upvotes: 1

Related Questions