General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 27th, 2003, 11:23 AM
fox66 fox66 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 7 fox66 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
creating GZIP files"on the fly"

Hi

is it possible to create a .gz file on the fly?
What I want to do is run a script (php) that will:

search a directory for all files matching certain criteria (done that)
store the file names from above into a array(done that)
create 1 .gz file with the other distinct file in it.(stuck here!)

is this possible with a "typical" installation of Unix and PHP?

Any help/pointers valued!

Thx

Reply With Quote
  #2  
Old January 28th, 2003, 08:34 PM
pentapenguin pentapenguin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 51 pentapenguin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 7 sec
Reputation Power: 16
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 (0<= $num++)
{
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.

Reply With Quote
  #3  
Old January 29th, 2003, 03:58 AM
fox66 fox66 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 7 fox66 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile

Many Thanks, I will give it a go!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > creating GZIP files"on the fly"


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap