A few days ago, a client requested a contact form submission to go to an autoimporting email address in a specific format. At first, this wasn’t an issue – a CSV file was fine. However, the client wanted a zipped CSV. At first I thought this was going to be difficult – Linux + Zip? – but it turns out PHP has some nifty functions to create and add to zip files.

Looking into it a bit further it appears it isn’t brilliant – for example, there is a lack of support for NOT compressing the archive – but it did exactly what I required.

I put together a little function to take care of it and make it re-usable. Take a look below.

The solution function

Making the call

Image Credit: Key Foster