• PHP Video Tutorials

PHP - bzip2 bzread() Function



bzread() function is a binary-safe bzip2 file read.

Syntax

string bzread( resource $bz [, int $length = 1024 ] )

bzread() function can read from a given bzip2 file pointer. The reading stops when length (uncompressed) bytes have been read, or EOF is reached, whichever comes first.

bzread() function can return an uncompressed data, or false on error.

Example

<?php
   $file = "/tmp/foo.bz2";
   $bz = bzopen($file, "r") or die("Couldn't open $file");
   $decompressed_file = "";
   
   while(!feof($bz)) {
      $decompressed_file .= bzread($bz, 4096);
   }
   bzclose($bz);

   echo "The contents of $file are: <br />\n";
   echo $decompressed_file;
?> 
php_function_reference.htm
Advertisements