note 127211 added to ziparchive.getstream

From: Date: Sat, 02 Jul 2022 10:24:53 +0000
Subject: note 127211 added to ziparchive.getstream
Groups: php.notes 
Request: Send a blank email to php-notes+get-218886@lists.php.net to get a copy of this message
Here a way to handle specific files from a zip archive without full extract : <?php $zip_file = '/path/to/file.zip'; // I wan to get stream a CSV files $zip = new ZipArchive(); $zip->open($zip_file); for ($i = 0; $i < $zip->numFiles; $i++) { // Check file by file $name = $zip->getNameIndex($i); // Retrieve entry name $extension = pathinfo($name, PATHINFO_EXTENSION); if ($extension === 'csv') { // I want to handle csv files $stream = $zip->getStream($name); // No stream index access before PHP 8.2 // Starting PHP 8.2 $zip->getStreamIndex() or $zip->getStreamName() // Do stuff with $stream // ... } } ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.133 (proxied: 2a01:e0a:968:1840:882:988:d1f6:8763) ---- Manual Page -- https://php.net/manual/en/ziparchive.getstream.php Edit -- https://main.php.net/note/edit/127211 Del: integrated -- https://main.php.net/note/delete/127211/integrated Del: useless -- https://main.php.net/note/delete/127211/useless Del: bad code -- https://main.php.net/note/delete/127211/bad+code Del: spam -- https://main.php.net/note/delete/127211/spam Del: non-english -- https://main.php.net/note/delete/127211/non-english Del: in docs -- https://main.php.net/note/delete/127211/in+docs Del: other reasons-- https://main.php.net/note/delete/127211 Reject -- https://main.php.net/note/reject/127211 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#218886) next »