January 28th, 2003, 08:34 PM
Join Date: Dec 2002
Time spent in forums: 36 m 7 sec
Reputation Power: 16
The following code might work.
(I don't have the appropriate file for PHP installed, so I can't actually test this code.)
//sample array of filenames
//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
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.