Tag Archives: zip

zip_read()

It reads the next entry in a ZIP file

Example

<?php
$zp = zip_open(“test.zip”);
while ($zipEntry = zip_read($zp)){
echo “Actuall file name -” . zip_entry_name($zipEntry);
if (zip_entry_open($zp, $zipEntry)){
zip_entry_close($zipEntry);
}
}
zip_close($zp);
?>

zip_entry_read()

It reads from an open entry in the ZIP file

Example

<?php
$zp = zip_open(“test.zip”);
while ($zipEntry = zip_read($zp)){
echo “Actuall file name -” . zip_entry_name($zipEntry);
if (zip_entry_open($zp, $zipEntry)){
zip_entry_close($zipEntry);
}
}
zip_close($zp);
?>

Output

Actuall file name -test.php

zip_entry_open()

It opens an entry in the ZIP file for reading

Example

<?php
$zp = zip_open(“test.zip”);
while ($zipEntry = zip_read($zp)){
echo “Actuall file name -” . zip_entry_name($zipEntry);
if (zip_entry_open($zp, $zipEntry)){
zip_entry_close($zipEntry);
}
}
zip_close($zp);
?>


zip_entry_name()

It returns the name of an entry in the ZIP file

Example

<?php
$zp = zip_open(“test.zip”);
while ($zipEntry = zip_read($zp)){
echo “Actuall file name -” . zip_entry_name($zipEntry);
if (zip_entry_open($zp, $zipEntry)){
zip_entry_close($zipEntry);
}
}
zip_close($zp);
?>

Output

Actuall file name -test.php

zip_entry_filesize()

It returns the actual file size of an entry in the ZIP file

Example

<?php
$zp = zip_open(“test.zip”);
while ($zipEntry = zip_read($zp)){
echo “Actaull file size -” . zip_entry_filesize($zipEntry);
if (zip_entry_open($zp, $zipEntry)){
zip_entry_close($zipEntry);
}
}
zip_close($zp);
?>

Output

Actaull file size -136

zip_entry_compressionmethod()

It returns the compression method of a directory entry

Example

<?php
$zp = zip_open(“test.zip”);
while ($zipEntry = zip_read($zp)){
echo “Compression Method -” . zip_entry_compressionmethod($zipEntry);
if (zip_entry_open($zp, $zipEntry)){
zip_entry_close($zipEntry);
}
}
zip_close($zp);
?>

Output

Compression Method -deflated

zip_entry_compressedsize()

It returns the compressed size of a directory entry

Example

<?php
$zp = zip_open(“test.zip”);
while ($zipEntry = zip_read($zp)){
echo “File size -” . zip_entry_compressedsize($zipEntry);
if (zip_entry_open($zp, $zipEntry)){
zip_entry_close($zipEntry);
}
}
zip_close($zp);
?>

Output

File size -103

zip_entry_close()

It closes an entry in the ZIP file

Example

<?php
$zp = zip_open(“test.zip”);
while ($zipEntry = zip_read($zp)){
echo “File Name -” . zip_entry_name($zipEntry);
if (zip_entry_open($zp, $zipEntry)){
zip_entry_close($zipEntry);
}
}
zip_close($zp);
?>

Output

File Name -test.php