PHP ZipArchive deleteIndex() Function Last Updated : 27 Mar, 2023 Comments Improve Suggest changes Like Article Like Report The ZipArchive::deleteIndex() function is an inbuilt function in PHP that is used to delete an entry from the zip archive using its index. Syntax: bool ZipArchive::deleteIndex(int $index) Parameters: This function accepts a single parameter that is described below: $index: This parameter holds the index number of entries that need to delete. Return Value: This function returns True on Success and False on Failure. Example 1: The following code demonstrates the delete() function. It deletes the third file as shown in the output. PHP <?php // Create a new ZipArchive object $zip = new ZipArchive; // Check for opening the zip file if ($zip->open('Geeks.zip', ZipArchive::CREATE)) { if($zip->deleteIndex(2)) { echo 'File deleted successfully'; } else { echo 'File not deleted'; } // Close the zip file $zip->close(); } // If zip file is not open/exist else { echo 'Failed to open zip file'; } ?> Output: Example 2: The following code demonstrates the delete() function with index 2. PHP <?php // Create a new ZipArchive object $zip = new ZipArchive; // Check for opening the zip file if ($zip->open('Geeks.zip', ZipArchive::CREATE)) { // Create new txt file and // add String to the file $zip->addFromString( 'GFG1.txt', 'Welcome to GeeksforGeeks' ); $zip->addFromString( 'GFG2.txt', 'A computer science portal' ); $zip->addFromString( 'GFG3.txt', 'Welcome to GeeksforGeeks' ); if($zip->deleteIndex(2)) { echo 'File deleted successfully'; } else { echo 'File not deleted'; } // Close the zip file $zip->close(); } // If zip file is not open/exist else { echo 'Failed to open zip file'; } ?> Output: Reference: https://www.php.net/manual/en/ziparchive.deleteindex.php Comment More infoAdvertise with us Next Article PHP ZipArchive deleteIndex() Function V vkash8574 Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP ZipArchive deleteName() Function The ZipArchive::deleteName() function is an inbuilt function in PHP that is used to delete an entry from the zip archive using its name. Syntax: bool ZipArchive::deleteName(string $name) Parameters: This function accepts a single parameter that is described below. $name: This parameter holds the fil 2 min read PHP ZipArchive close() Function The PHP ZipArchive::close() function is an inbuilt function in PHP that is used to close the opened archive file and save the changes. This function is called after performing all operations on the zip file. If the zip archive does not contain any file then by default zip file is deleted.Syntax:bool 2 min read PHP ZipArchive extractTo() Function The ZipArchive::extractTo() function is an inbuilt function in PHP that is used to extract the zip archive content in a folder.Syntax:bool ZipArchive::extractTo( string $pathto, array|string|null $files = null)Parameters: This function accepts two parameters that are described below:$pathto: This pa 2 min read PHP | DsSequence remove() Function The Ds\Sequence::remove() function is an inbuilt function in PHP which is used to remove and return a value by index. Syntax: mixed abstract public Ds\Sequence::remove ( int $index ) Parameters: This function accepts a single parameter $index which holds the index of value to remove. Return value: T 1 min read PHP DsSet remove() Function The Ds\Set::remove() function of Ds\Set class in PHP is an inbuilt function which is used to remove specific values from a Set instance. This function can remove both single or multiple values from a Set. Syntax: void public Ds\Set::remove ([ mixed $...values ] ) Parameter: This function accepts the 2 min read PHP | ftp_delete() function The ftp_delete() function is an inbuilt function in PHP which is used to delete a file on the FTP server. Syntax:Â ftp_delete( $ftp_connection, $file ) Parameters: This function accepts two parameters as mentioned above and described below:Â Â $ftp_connection: It is required parameter. It specifies t 2 min read PHP | DOMNode removeChild() Function The DOMNode::removeChild() function is an inbuilt function in PHP which is used remove child from list of children. Syntax: DOMNode DOMNode::removeChild( DOMNode $oldnode ) Parameters: This function accepts a single parameter $oldnode which holds the child to remove. Return Value: This function retu 1 min read PHP | DsDeque remove() Function The Ds\Deque::remove() function is an inbuilt function in PHP which is used to remove and return the index value. Syntax: public Ds\Deque::remove( $index ) : mixed Parameters: This function accepts single parameter $index which holds the index of Deque for which the element is to be returned and rem 2 min read PHP | DOMElement removeAttribute() Function The DOMElement::removeAttribute() function is an inbuilt function in PHP which is used to remove a attribute with specific name from the element. Syntax: bool DOMElement::removeAttribute( string $name ) Parameters: This function accepts a single parameter $name which holds the name of the attribute. 2 min read PHP | DsVector remove() Function The Ds\Vector::remove() function is an inbuilt function in PHP that is used to remove an element from the Vector at the specified ï¼index argument and returns the removed element. Syntax: mixed public Ds\Vector::remove( $index ) Â Parameters: This function does not accept any parameter. Â Return Value: 1 min read Like