To extract files from a zip archive in PHP, you can use the built-in ZipArchive class. Here is an example:
// Specify the path of the zip archive
$zipPath = 'path/to/archive.zip';
// Create a new instance of ZipArchive
$zip = new ZipArchive;
// Open the zip archive
if ($zip->open($zipPath) === true) {
// Specify the destination directory to extract files
$extractPath = 'path/to/extracted/files';
// Extract all files from the archive
$zip->extractTo($extractPath);
// Close the zip archive
$zip->close();
echo 'Files extracted successfully!';
} else {
echo 'Failed to open the zip archive.';
}
Replace path/to/archive.zip
with the actual path of your zip archive file, and path/to/extracted/files
with the desired destination directory where you want to extract the files.
Note: Before using this code, make sure that the PHP Zip extension is enabled on your server.