Simple PHP function that can be used to read data of a ZIP archive with PHP. The function receives a string with the path-name of the Zip file; and returns a two dimensional Array with data of each file in archive (name, actual_filesize, compressed_size).
<?php
// Function to Read ZIP Archive. Returns a two dimensional Array with data of each file in archive
function readZipData($zip_file) {
  // PHP-MySQL Course - http://coursesweb.net/php-mysql/
  $zip_data = array();     // will store arrays with data of each file in archive
  $zip = zip_open($zip_file);

  // if the $zip_file is opened, traverse the archive
  if($zip) {
    while ($zip_entry = zip_read($zip)) {
      // adds in $zip_data an array with data of each file in archive
      $zip_data[] = array(
        'name' =>zip_entry_name($zip_entry),
        'actual_filesize' => zip_entry_filesize($zip_entry),
        'compressed_size' => zip_entry_compressedsize($zip_entry)
      );
    }
    zip_close($zip);

    return $zip_data;
  }
  else  echo "Failed to open $zip_file";
}

  /* Example */

//the path-name of the zip file
$zip_file = 'dir/file.zip';

// get data of the $zip_file
$zip_data = readZipData($zip_file);

// output the resulted array (with data for archived files)
echo '<pre>';
var_export($zip_data);
echo '</pre>';
?>
This example will return an array like this:
array (
  0 => 
  array (
    'name' => 'file1.txt',
    'actual_filesize' => 388984,
    'compressed_size' => 114339,
  ),
  1 => 
  array (
    'name' => 'image.jpg',
    'actual_filesize' => 16942,
    'compressed_size' => 16801,
  ),
  2 => 
  array (
    'name' => 'audio/music.mp3',
    'actual_filesize' => 16942,
    'compressed_size' => 16806,
  )
)

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag adds a new line into a paragraph?
<b> <br> <p>
First line ...<br>
Other line...
Which CSS property can be used to add space between letters?
text-size word-spacing letter-spacing
#id {
  letter-spacing: 2px;
}
What JavaScript function can be used to get access to HTML element with a specified ID?
getElementById() getElementsByTagName() createElement()
var elm = document.getElementById("theID");
var content = elm.innerHTML;
alert(content);
Click on the "echo" correct instruction.
echo "CoursesWeb.net" echo "CoursesWeb.net"; echo ""CoursesWeb.net";
echo "Address URL: http://CoursesWeb.net";
Read ZIP archive data with PHP

Last accessed pages

  1. Inheritance - Parent class and Child class (1109)
  2. PHP PDO - exec (INSERT, UPDATE, DELETE) MySQL (27235)
  3. Get the value of multiple selected checkboxes with same name (4347)
  4. Add, Change, and Remove Attributes with jQuery (21290)
  5. Common PHP Errors and Solutions (4654)

Top accessed pages

  1. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (43787)
  2. PHP-MySQL free course, online tutorials PHP MySQL code (33177)
  3. Read Excel file data in PHP - PhpExcelReader (33092)
  4. Get Attribute (ID, Class, Name, Title, Src) with jQuery (29923)
  5. PHP PDO - exec (INSERT, UPDATE, DELETE) MySQL (27235)