$zip = new \ZipArchive;

  public function open($apk_file, $xml_file='AndroidManifest.xml'){
    $zip = new \ZipArchive;
    if ($zip->open($apk_file) === TRUE) {
      $xml = $zip->getFromName($xml_file);
      $zip->close();
      if ($xml){
        try {
            //var_dump($xml);
          return $this->parseString($xml);
        }catch (Exception $e){
        }
      }
    }
    return false;
  }

 

<?php

  function open($zip_file, $txt_file_path){
    $zip = new \ZipArchive;
    if ($zip->open($zip_file) === TRUE) {
      $txt = $zip->getFromName($txt_file_path);
      $zip->close();
      if ($txt){
        try {
            var_dump($txt);          
        }catch (Exception $e){
        }
      }
    }   
  }

$zip_file='testZip.zip';
$txt_file_path='aaa.txt';open($zip_file, $txt_file_path);
$txt_file_path='bbb.txt';open($zip_file, $txt_file_path);
$txt_file_path='ccc/ccc.txt';open($zip_file, $txt_file_path);
$txt_file_path='ccc/ddd.txt';open($zip_file, $txt_file_path);

/*
string 'aaa' (length=3)
string 'bbb' (length=3)
string 'ccc' (length=3)
string 'ddd
' (length=5)
*/
?>

 

posted @ 2018-02-28 09:13  sky20080101  阅读(618)  评论(0)    收藏  举报