Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
zip_entry_name() function in PHP
The zip_entry_name() function returns the name of a directory entry inside a ZIP archive. This function is part of PHP's ZIP extension and works with ZIP archives opened using zip_open().
Syntax
zip_entry_name(zip_entry)
Parameters
zip_entry − A directory entry resource from a ZIP file, obtained using
zip_read()on an archive opened withzip_open().
Return Value
The zip_entry_name() function returns the name of the ZIP archive entry as a string on success, or FALSE on failure.
Example
The following example demonstrates how to list all file names in a ZIP archive using zip_entry_name() −
<?php
$zip = zip_open("new.zip");
if ($zip) {
while ($zip_entry = zip_read($zip)) {
echo "File Name = ". zip_entry_name($zip_entry). "<br />";
}
zip_close($zip);
}
?>
Output
File Name = amit.txt File Name = peter.txt File Name = result.html File Name = demo.java File Name = settings.ini
Note
The ZIP extension functions like zip_entry_name() are deprecated as of PHP 8.0.0. It is recommended to use the ZipArchive class for ZIP file operations in modern PHP applications.
Conclusion
The zip_entry_name() function provides a simple way to retrieve file names from ZIP archives. However, consider migrating to the ZipArchive class for better functionality and future compatibility.
