class ZipExtension

Transformations class

Methods

__construct()

Constructor

array
getContents(string $file, string $specific_entry = 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|bool
extract(string $file, string $entry)

Extracts the content of $entry.

string|bool
createFile(array|string $data, array|string $name, integer $time = 0)

Creates a zip file.

Details

at line 28
__construct()

Constructor

at line 42
array getContents(string $file, string $specific_entry = null)

Gets zip file contents

Parameters

string $file path to zip file
string $specific_entry regular expression to match a file

Return Value

array ($error_message, $file_data); $error_message is empty if no error

at line 118
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

at line 141
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 wern't any files or an error occured.

at line 160
string|bool 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|bool data on sucess, false otherwise

at line 183
string|bool createFile(array|string $data, array|string $name, integer $time = 0)

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
integer $time the current timestamp

Return Value

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