Yngvarr

Generation

generate functionSat, 07 Jan 2023

generate gz archive

function tar_gz($source, $destination) { if (extension_loaded('zlib')) { if (is_file($source)) { $file = basename($source); $source = dirname($source); } else { $file = basename($destination); $source = $source; } if (!file_exists("$destination/$file.gz")) { $destination = dirname($destination); if (!extension_loaded('zlib')) { return false; } $archive = new PharData("$source/$file"); $archive->compress(Phar::GZ); unset($archive); rename("$source/$file.gz", "$destination/$file.gz"); return "$destination/$file.gz"; } } return false; }

Questions about programming?Chat with your personal AI assistant