The script looks like it should work. The reason the files are not added is that this condition fails
if(file_exists($file)) {
Either, the files you specified really don't exist, or there is a problem with the path. But, I'm not presently on a windows machine, so I can't check what might go wrong. Perhaps try replacing / with \ in the path. Additionally if safe_mode is enabled, then file_exists will return false for existing files for which you have no access rights.
Also, I'd make this change
if(is_array($files)) {
//cycle through each file
foreach($files as $file) {
//make sure the file exists
if(file_exists($file)) {
// $valid_files[] = $file;
$zip->addFile($file);
}
}
}
Then take the above code block and substitute it for
//add the files
foreach($valid_files as $file) {
$zip->addFile($file,$file);
}
The more and/or larger files you add and the more users around who may rename, move or delete files, the more important this is. Since your script first checks if the files exist, and only tries to add them some time later, it is entirely possible that someone else makes changes on disk so that a file no longer exist when your script actually tries to add it.
Even with my suggested change, there is of course a small risk this could happen, but at least it minimizes time between file accesses in if (file_exists) and zip->add.