Sure you can, it's pretty simple with ZipArchive
// What the array structure should look like [filename => file contents].
$files = array('one.txt' => 'contents of one.txt', ...);
// Instantiate a new zip archive.
$zip_file = new ZipArchive;
// Create a new zip. This method returns false if the creation fails.
if(!$zip_file->open('directory/to/save.zip', ZipArchive::CREATE)) {
die('Error creating zip!');
}
// Iterate through all of our files and add them to our zip stream.
foreach($files as $file => $contents) {
$zip_file->addFromString($file, $contents);
}
// Close our stream.
$zip_file->close();