php不解压zip,直接读取zip内容

直接上代码

        $contents = '';
        $zip_path = 'xx/aaa.zip';
        $read_path = 'xx/11.txt';
        $z = new \ZipArchive();
        if ($z->open($zip_path)) {
            $fp = $z->getStream($read_path);
            if (!$fp) exit("failed\n");

            while (!feof($fp)) {
                $contents .= fread($fp, 2);
            }

            fclose($fp);
            file_put_contents('t', $contents);
            // 如无意外将输出读取到的内容
            echo $contents;
        }

猜你喜欢

转载自blog.csdn.net/u010775335/article/details/127922805
今日推荐