2016-07-25 51 views

回答

3

如果你有安裝了zip擴展,它應該已經註冊郵編://compression wrapper。嘗試以下操作:

$result = file_get_contents('zip://path_to_my.zip#subDir/foo.txt'); 
+0

真棒,它工作。乾杯。 – Sami

2

有兩種不同的方法可以做到這一點。一種是使用使用Zip wrapper這樣的:

$result = file_get_contents('zip://foo.zip#dirName/bar.txt'); 

更新:下面似乎沒有現在的工作,目前還不能確定原因。 或者您可以使用Zip Archive class這樣的:

$zipFile = new ZipArchive(); 
if ($zipFile->open(dirname(__FILE__) . '/foo.zip')) { 
    $string = $zipFile->getFromName("dirName/bar.txt"); 
} 

相關問題