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 with zip_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.

Updated on: 2026-03-15T07:30:42+05:30

103 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements