Compdigitec Labs

« | Home | »

Simple way to read bzip2 compressed files in PHP

By admin | August 9, 2008

If you are looking for a way to read quick way to read a compressed bzip2 file’s contents, look no further. We have made a function that works similar to the way file_get_contents works.

The code is released under the GPL v2 or later license.

<?php
/**
* Reads an uncompressed file from a bzip2 file
*
* @function file_bzip2_contents
* @author Compdigitec - http://www.compdigitec.com/
* @copyright (C)Copyright 2008 Compdigitec. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt
* @param string $filename The filename of the bz2 compressed file
* @param resource $res An existing resource opened by bzopen
* @return string The contents of the bzip2 file
*/

function file_bzip2_contents($filename,$res = null) {
$file = strval($filename); // Avoid bad input
if($res === null) {
$res = bzopen($filename,'r');
$a = '1qza';
};
$contents = bzread($res);
if($a == "1qza") {
bzclose($res);
}
return $contents;
}

?>

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: PHP | 14 Comments »

14 Responses to “Simple way to read bzip2 compressed files in PHP”

  1. opensea nft Says:
    February 23rd, 2022 at 11:27

    … [Trackback]

    […] Information to that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  2. buy canik guns USA online Says:
    April 11th, 2022 at 23:05

    … [Trackback]

    […] Information on that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  3. tristar arm store Says:
    April 14th, 2022 at 10:59

    … [Trackback]

    […] Info to that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  4. buy cvv Says:
    May 3rd, 2022 at 23:48

    … [Trackback]

    […] Info on that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  5. sell my home Says:
    June 5th, 2022 at 05:20

    … [Trackback]

    […] Read More Information here on that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  6. Godrej Splendour Says:
    June 9th, 2022 at 11:23

    … [Trackback]

    […] Read More on that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  7. psilocybin mushrooms for sale Says:
    July 18th, 2022 at 02:56

    … [Trackback]

    […] There you can find 83412 additional Info on that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  8. Morning Prayer Says:
    August 13th, 2022 at 17:35

    … [Trackback]

    […] Find More on on that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  9. here Says:
    August 25th, 2022 at 10:05

    … [Trackback]

    […] Info on that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  10. maxbet Says:
    August 26th, 2022 at 07:22

    … [Trackback]

    […] Find More Info here on that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  11. Buy ammo for sale Says:
    August 27th, 2022 at 22:34

    … [Trackback]

    […] Read More Info here to that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  12. Text Inmate Says:
    August 31st, 2022 at 16:45

    … [Trackback]

    […] Find More Information here to that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  13. sbo Says:
    September 1st, 2022 at 18:29

    … [Trackback]

    […] There you will find 72652 more Info to that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

  14. Alexa Nikolas manipulator Says:
    November 23rd, 2022 at 15:21

    … [Trackback]

    […] Here you will find 90261 more Info to that Topic: compdigitec.com/labs/2008/08/09/simple-way-to-read-bzip2-compressed-files-in-php/ […]

Comments