How to extract .zip archive (PHP)

A function that allows you to extract files from a zip archive to a specified folder:

function extractZip($filePath, $extractTo){
$zip = new ZipArchive();
$result = $zip->open($filePath);
if ($result === TRUE) {
return $result;

$file = ''; // change to your file path
$folder = 'myfolder'; // change to your folder path

extractZip($file, $folder);

Note: you need a zlib library for this code to work



No comments yet, you can leave yours: