Work with ZIP-archives in PHP 5.2+

Starting with PHP 5.2 you can use useful library ZipArchive for easy working with ZIP archives.
(If your PHP version les 5.2 you’ll get error: class ziparchive not found)

Steps for easy working with ZipArchive
Init:

$zip = new ZipArchive;

Read ZIP archive:

$zip->open('{file_location_path}');

Create new ZIP archive (just add ZipArchive::CREATE):

$zip->open('{file_location_path}', ZipArchive::CREATE);

Example of extracting archive on your server:

$zip = new ZipArchive;
if ($zip->open('{file_location_path}') === true){
	$zip->extractTo('{file_location_extraction_path}');
	$zip->close();
}else{
	echo 'Archive file is not found';
}

Example of creating archive on your server:
Continue reading Work with ZIP-archives in PHP 5.2+