This example will explain about converting text files into bzip file.This example will explain about converting text files into bzip file.
Converting text file into bzip file
In this example, you will see, how to convert a text file into bzip file. In this example, we have printed 'I am a good programmer' along with converting a file into bzip file.
Opne the PHP tag and first select a file to be converted into bzip file.
Open the file and write into bzip file
close the file.
Again, open the file, and read it, close the file.
close the php tag.
Select a file to be converted. into bzip file.
# Read and Write a bz2 file
$bzfilename = "text.bz2";
$string = " I am a good programmer.\n";
$bz2 = bzopen($bzfilename, "w");
$bz = bzopen($bzfilename, "r");
echo bzread($bz2, 10);
The out put:
'I am a good programmer.'