
January 28th, 2003, 07:34 PM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 51
Time spent in forums: 36 m 7 sec
Reputation Power: 6
|
|
Hi.
The following code might work.
(I don't have the appropriate file for PHP installed, so I can't actually test this code.)
PHP Code:
<?php
//sample array of filenames
$fileNamesArray["file1"];
$fileNamesArray["file2"];
$fileNamesArray["file3"];
//count the number of items in the array
$num = count($fileNamesArray);
//filename of compressed file (in same directory)
$file = "compressedfile.txt.gz";
//open gz -- 'w9' is highest compression
$fp = gzopen ($filename, 'w9');
//loop through array and write each line into the compressed file
for (i = 0; i <= $num; i ++)
{
gzwrite ($fp, "$fileNamesArray[i]\n");
}
//close the file
gzclose ($fp);
?>
Check out the PHP manual for more info.
PHP Manual Ref
I also really recommend "PHP Advanced for the World Wide Web" by Larry Ullman for more info on this and other PHP subjects.
|