PHP导入包装在zip文件中的XML feed

I want to automate the following: Once a day my cronjob starts a PHP script that obtains a zipped XML file from an URL.

What would be the best way to handle this? Is there any way to directly read the XML file from within the zip file?

Right now, i'm just downloading the zipped file to the server and manually unpacking it later that day.

Any ideas? All suggestions are very much welcome.

You can use PHP's ZipArchive coupled with cURL to download and read the zip file.

Also, the ZipArchive class has a method called getStream which allows you to then use fread to access the contents without explicitly extracting the file.

The only problem I see if that the zip does have to be saved somewhere for PHP's library to read it. But, given you're already doing this, it shouldn't be an issue.

If you need an example, leave me a comment and I can write on up.

There is a collection of zip-related functions that can be used in PHP.

The problem with these is that it requires the compressed file to exist on the server (not just loaded from an external server somewhere using, for example, $file = file($url);).

If you were to save the file to your server then you could use $zip = zip_open($filename) and zip_read($zip) to process the zip file.