Uncompress compressed string

I’ve got a script which fetches zipped content from a web page. Under normal circumstances the browser would donwload this as a zip file, but for my script the remote server just returns the compressed string, and I’m trying to figure out how to uncompress it. Apparently it’s compressed using PKzip if that’s any help.

I’ve tried just writing it to a file

$fh = fopen("zipfile.zip","w");
fwrite($fh,$zippedString);

But when I try to open the zip file (after writing it) it appears to be invalid.

I’ve tried gzuncompress() and gzinflate(), eg

echo gzinflate($zippedString);

but it still outputs gibberish.

Any ideas?

Use php zip extension

I’ve looked through the functions there, but they all seem to deal with a zipped file, rather than the actual zipped contents. What I’ve got is the zipped output from a remote server.

Could you post the url of the zip file and your script’s code?

Have re-visited this problem and got it sussed.
I think the main problem I had was that I was grabbing a stream straight from a website, and part of this stream was the headers. I needed to remove the headers and then the content of the response was a valid zip file.
I unzipped it using the pclzip class. I’m not sure whether the gzinflate would have been correct or incorrect for zipped content, but I think the headers were the main problem.