首页 > 解决方案 > PHP while($content = zip_read()) 缺少文件

问题描述

我使用脚本浏览压缩文件的内容,脚本只是错过了其中一些

我们在存储发票(平面文件)的服务器上有多个 ZIP 存档。我使用以下代码搜索它们:

foreach($zip_files as $zip_file){

      echo $zip_file . "[" . $counter . "/" . $count . "]\n";
      $counter++;
      //Opening and reading zip file
      $zip_content = zip_open($archive_path . "\\" . $zip_file); 

      while($file = zip_read($zip_content)){

        $filename = zip_entry_name($file);

        if(strpos($filename,".rcv")){


          $content = zip_entry_read($file,4086);
          if(strpos($content, "<MvxEnvelope>")){

            if(strpos($content, "<Field>TETINR</Field>")){

              $type = "TETINR";
              $TINR_position = strpos($content, "<Field>TETINR");
              $DIVI_position = strpos($content, "<Field>DIVI");
              $TINR = substr($content,($TINR_position + 28), 10);
              $DIVI = substr($content,($DIVI_position + 26), 3);
              fwrite($map, $zip_file . ";" . $filename . ";" . $DIVI . ";" . $TINR . ";" . $type . "\n");

            }
          }
        }
      }   
    }

我希望脚本遍历所有文件,不要错过其中的一些。提前谢谢了

标签: phpzip

解决方案


推荐阅读