PHP

HOW TO READ ZIP FILES IN PHP

OPEN ZIP FILE $zip = new ZipArchive; $zip->open("FILE.ZIP", ZipArchive::RDONLY);

USING ZIP ARCHIVE (A)

01

USING ZIP ARCHIVE (B)

02

FILES & FOLDERS IN ZIP $total = $zip->count(); for ($i=0; $i<$total; $i++) { print_r($zip->statIndex($i)); }

USING ZIP ARCHIVE (C)

03

READ FILE $content = $zip->getFromIndex(0); $content = $zip-> getFromName("FILE.TXT"); $zip->close();

$zip = zip_open("FILE.ZIP"); while ($entry = zip_read($zip)) {   GET FILE NAME & SIZE   $name = zip_entry_name($entry);   $size = zip_entry_filesize($entry);

LEGACY READ ZIP

04

  READ FILE CONTENT   zip_entry_open($zip, $entry);   $contents = zip_entry_read($entry);   zip_entry_close($entry); } zip_close($zip);