Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The approach differs with the compression mechanism you use, since the available libraries all use different interfaces; Exemplary, I'll show bzip2 here since that seems to be the simplest to me. Locally, just execute <code>bzip2 &lt;file&gt;</code> on any *ix command line shell; on Windows you could use e.g. 7-Zip for creating a .bz2 file.</p> <p>In your php, you will want to read the whole file content instead of single lines (single lines don't make much sense in a compressed file). So you'll have to change your code starting from opening the files:</p> <pre><code>/* // Open the file if (!($file = fopen ($temp_name, "r"))) die ("Could not open the file $file\n"); // Read the first line $string = fgets ($file, 1024); */ $compressed_filecontent = file-get-contents($temp_name); $filecontent = bzdecompress($compressed_filecontent); ... // instead of reading from the file line by line, // you'd then have to split up the $filecontent variable // in separate lines and work on them </code></pre> <p>Note: of the <a href="http://www.php.net/manual/en/refs.compression.php" rel="nofollow">"compression" formats</a> where there is a PHP library available for, only LZF is similarly simple to use (you'd just have to replace <a href="http://www.php.net/manual/en/function.bzdecompress.php" rel="nofollow">bzdecompress</a> with <a href="http://www.php.net/manual/en/function.lzf-decompress.php" rel="nofollow">lzf-decompress</a>); that is because the other formats (like ZIP and RAR) are not only compression formats but also archiving formats (meaning that such files can hold multiple compressed files). That makes reading them a little harder - see the <a href="http://www.php.net/manual/en/refs.compression.php" rel="nofollow">documentation</a> for more info.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload