This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // works on single-file non-ZIp64 zip files compressed with deflate (AKA a common case), licensed MIT | |
function getLinesFromZippedCSVfromURL(string $url) : \Generator | |
{ | |
$stream = fopen($url, 'rb'); | |
fread($stream, 4 + 2 + 2 + 2 + 2 + 2 + 4); // skip up to compressed size | |
// bindec() was doing weird things, hence converting through hex first | |
// sttrev() to match endian-ness to expectations; zip file values are little-endian |