su internet ho trovato la soluzione che riadattata assume questa forma:
Codice PHP:
function scriviZip($doveScriverlo$datiZip)
{
    if (
extension_loaded('zip') === true)
    {
        if (
file_exists($datiZip) === true)
        {
                
$zip = new ZipArchive();

                if (
$zip->open($doveScriverloZIPARCHIVE::CREATE) === true)
                {

                        if (
is_dir($datiZip) === true)
                        {
                                
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($datiZip), RecursiveIteratorIterator::SELF_FIRST);

                                foreach (
$files as $file)
                                {

                                        if (
is_dir($file) === true)
                                        {
                                                
$zip->addEmptyDir(str_replace($datiZip '/'''$file '/'));
                                        }

                                        else if (
is_file($file) === true)
                                        {
                                                
$zip->addFromString(str_replace($datiZip '/'''$file), file_get_contents($file));
                                        }
                                }
                        }

                        else if (
is_file($datiZip) === true)
                        {
                                
$zip->addFromString(basename($datiZip), file_get_contents($datiZip));
                        }
                }

                return 
$zip->close();
        }
    }

    return 
false;

La usi chiunque ne abbia bisogno!