I have a directory which contains a set of zipped files. each of these files has foo.txt file in it.
How can I read this text file from each zip?
I know glob
is used to list all files from the directory
PHP has an extension that allows you to work with ZIP archives.
Note that to access that one file you don't need to unzip the whole archive. The ZipArchive::extractTo method allows you to specify what to extract.
$zip = new ZipArchive;
$res = $zip->open('test.zip');
$zip->extractTo('my/extract/folder/', 'foo.txt');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With