class ZipExtension (View source)

Transformations class

Methods

__construct(ZipArchive|null $zip = null)

No description

array
getContents(string $file, string|null $specificEntry = null)

Gets zip file contents

string|false
findFile(string $file, string $regex)

Returns the filename of the first file that matches the given $file_regexp.

int
getNumberOfFiles(string $file)

Returns the number of files in the zip archive.

string|false
extract(string $file, string $entry)

Extracts the content of $entry.

string|false
createFile(array|string $data, array|string $name)

Creates a zip file.

Details

__construct(ZipArchive|null $zip = null)

No description

Parameters

ZipArchive|null $zip

array getContents(string $file, string|null $specificEntry = null)

Gets zip file contents

Parameters

string $file

path to zip file

string|null $specificEntry

regular expression to match a file

Return Value

array

string|false findFile(string $file, string $regex)

Returns the filename of the first file that matches the given $file_regexp.

Parameters

string $file

path to zip file

string $regex

regular expression for the file name to match

Return Value

string|false

the file name of the first file that matches the given regular expression

int getNumberOfFiles(string $file)

Returns the number of files in the zip archive.

Parameters

string $file

path to zip file

Return Value

int

the number of files in the zip archive or 0, either if there weren't any files or an error occurred.

string|false extract(string $file, string $entry)

Extracts the content of $entry.

Parameters

string $file

path to zip file

string $entry

file in the archive that should be extracted

Return Value

string|false

data on success, false otherwise

string|false createFile(array|string $data, array|string $name)

Creates a zip file.

If $data is an array and $name is a string, the filenames will be indexed. The function will return false if $data is a string but $name is an array or if $data is an array and $name is an array, but they don't have the same amount of elements.

Parameters

array|string $data

contents of the file/files

array|string $name

name of the file/files in the archive

Return Value

string|false

the ZIP file contents, or false if there was an error.