PHP | zip_read() Function Last Updated : 28 Nov, 2022 Comments Improve Suggest changes Like Article Like Report The zip_read() function is an inbuilt function in PHP which is used to read an entity present in the opened zip archive. The zip resource is to be read and sent as parameters to the zip_read() function and it returns a resource containing file within the zip archive on success, or FALSE if there is no more entry to read. Syntax: zip_read( $zip ) Parameters: This function accepts single parameter $zip which is mandatory. It is used to specify the zip entry resource. Return Value: It returns a resource containing file within the zip archive on success, or FALSE if there is no entry to read. Errors And Exceptions: The zip_read() function returns an ER_OPEN error if the zip archive is invalid.The zip_read() function returns an ER_NOZIP error if the zip archive is empty. Below programs illustrate the zip_read() function in PHP: Program 1: Suppose a zip file article.zip contains the following files: article.zip content.xlsx gfg.pdf image.jpeg php <?php // Opening a zip archive $zip_handle = zip_open("article.zip"); // Reading a zip file while($zip_entry = zip_read($zip_handle)) { $file = zip_entry_name($zip_entry); echo("File Name: " . $file . "<br>"); } // Close the opened zip file zip_close($zip_handle); ?> Output: File Name: article/article.zip File Name: article/content.xlsx File Name: article/gfg.pdf File Name: article/image.jpeg Program 2: Suppose a zip file article.zip contains the following files and directory: Directory: img geeksforgeeks.pnggeeksforgeeks1.png content.xlsx gfg.pdf image.jpeg php <?php // Opening a zip file $zip_handle = zip_open("article.zip"); if(is_resource($zip_handle)) { // Reading a zip entry file while($zip_entry = zip_read($zip_handle)) { $file = zip_entry_name($zip_entry); echo("File Name: " . $file . "<br>"); } // Close the opened xop file zip_close($zip_handle); } else echo("Zip Archive cannot be opened."); ?> Output: File Name: article/content.xlsx File Name: article/gfg.pdf File Name: article/image.jpeg File Name: article/img/ File Name: article/img/geeksforgeeks.png File Name: article/img/geeksforgeeks1.png Related Articles: PHP | zip_entry_close() FunctionPHP | zip_close( ) FunctionPHP | zip_entry_compressedsize() Function Reference: http://php.net/manual/en/function.zip-read.php Comment More infoAdvertise with us Next Article PHP | zip_read() Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-file-handling PHP-function +1 More Practice Tags : Misc Similar Reads PHP | zip_entry_read() Function The zip_entry_read() function is an inbuilt function in PHP which is used to read the contents from an opened zip archive entry. The zip entry is being read and the number of bytes to be returned can be sent as a parameter to the zip_entry_read() function and it returns the content of the specified 3 min read PHP | readdir() Function The readdir() function in PHP is an inbuilt function which is used to return the name of the next entry in a directory. The method returns the filenames in the order as they are stored in the filenamesystem. The directory handle is sent as a parameter to the readdir() function and it returns the ent 2 min read PHP | readfile( ) Function The readfile() function in PHP reads a file and writes its contents directly to the output buffer (usually the browser). Itâs an easy way to show a file without reading it line by line yourself.If thereâs a problem reading the file, like if it doesnât exist, PHP will usually show an error message. T 3 min read PHP | rewind( ) Function The rewind() function in PHP is an inbuilt function which is used to set the position of the file pointer to the beginning of the file. Any data written to a file will always be appended if the file is opened in append ("a" or "a+") mode regardless of the file pointer position. The file on which the 2 min read PHP scandir( ) Function In this article, we will see how to get all the files from the current or specified directory using the scandir() function in PHP. The scandir() function in PHP is an inbuilt function that is used to return an array of files and directories of the specified directory. The scandir() function lists th 3 min read PHP | zip_open() Function The zip_open() function is an inbuilt function in PHP which is used to open a zip archive for reading. The zip_open() function creates a new stream and establishes a connection between the stream and a Zip Archive. The filename is sent as a parameter to the zip_open() function and it returns a valid 2 min read PHP | is_readable( ) Function The is_readable() function in PHP used to check whether the specified file exists and is readable or not. The name of the file is sent as a parameter to the is_readable() function and it returns True if the file exists and is readable. is_readable() function returns False for streams, for example, p 2 min read PHP | XMLReader read() Function The XMLReader::read() function is an inbuilt function in PHP which is used to move to next node in document. Thus this function is used to traverse through the XML document. Syntax: bool XMLReader::read( void ) Parameters: This function doesnât accepts any parameter. Return Value: This function retu 2 min read PHP | zip_close( ) Function The zip_close() function is an inbuilt function in PHP which is used to close a zip archive file opened by the zip_open() function. The zip_close() causes the stream to be closed and the connection to the corresponding Zip Archive to be broken. The zip resource which has been opened by the zip_open( 2 min read PHP String Functions Strings are a fundamental data type in PHP, used to store and manipulate text. PHP provides a wide variety of built-in string functions. These functions perform various operations such as string transformations, character manipulations, encoding and decoding, and formatting, making string handling s 6 min read Like