Skip to content

Instantly share code, notes, and snippets.

@vyspiansky
Last active March 1, 2021 16:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyspiansky/6efa5a231019bea63c3d1c5d8a3e7279 to your computer and use it in GitHub Desktop.
Save vyspiansky/6efa5a231019bea63c3d1c5d8a3e7279 to your computer and use it in GitHub Desktop.
PHP: unzip ZIP file
<?php
// Path to zip file
$file = '...';
// Destination directory for unzipped files
$dest = '...';
// Create object
$zip = new ZipArchive();
// Open archive
if ($zip->open($file) !== true) {
die('Could not open archive');
}
// Extract contents to destination directory
$zip->extractTo($destination);
// Close archive
$zip->close();
echo 'Archive extracted to directory';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment