PHP code example of seblucas / tbszip

1. Go to this page and download the library: Download seblucas/tbszip library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

seblucas / tbszip example snippets


$zip = new clsTbsZip(); // instantiate the class

$zip->Open('archive1.zip'); // open an existing zip archive

$ok = $zip->FileExists('innerfolder/subfile1.txt'); // check if a sub-file exist in the archive

$txt = $zip->FileRead('subfile2.txt'); // retrieve the content of a sub-file

... // some work on the $txt contents

$zip->FileReplace('subfile2.txt', $txt, TBSZIP_STRING); // replace the existing sub-file

$zip->FileReplace('subfile3.txt', false); // delete the existing sub-file

$zip->FileAdd('subfile4.txt', $txt3, TBSZIP_STRING); // add a new sub-file

$zip->Flush(TBSZIP_FILE, 'archive1_new.zip'); // flush the modifications as a new archive

$zip->Close(); // close the current archive

Open($ArchFile, $UseIncludePath=false)

CreateNew()

FileExists($NameOrIdx)

FileRead($NameOrIdx, $Uncompress=true)

FileReplace($NameOrIdx, $Data, $DataType=TBSZIP_STRING, $Compress=true)

FileAdd($Name, $Data, $DataType=TBSZIP_STRING, $Compress=true)

FileCancelModif($NameOrIdx)

FileGetState($NameOrIdx)

Flush($Render=TBSZIP_DOWNLOAD, $File='', $ContentType='')

Debug()

Close()

ArchFile

CdFileLst

LastReadIdx

LastReadComp

DisplayError

Error