2017-07-31 8 views
1

私はRarEntry::getName()方法はをアーカイブするための唯一の道相対を返します。このファイルを読み、PHPの配列にPHPするRarArchive&のfile_get_contents

$file="archive.rar"; 
$ext = pathinfo($file, PATHINFO_EXTENSION); 
$tmp=$_SERVER['DOCUMENT_ROOT'].'/tmp'; 

if($ext=='rar'){ 
    $archive = RarArchive::open($file); 
    $entries = $archive->getEntries(); 
    foreach ($entries as $entry) { 
     echo file_get_contents($entry->getName());// not working 
     $entry->extract($tmp); 
    } 
    $archive->close(); 
} 
+0

「コンテンツをPHP配列に入れてみましたか?」 – BenRoob

+0

私はすべてのreadme.txtファイルを読んで公開したい –

答えて

0

をコンテンツを入れて、すべての* .TXTファイルを検索し、オープンRARアーカイブを必要としています。 file_get_contents()関数はこのアーカイブについては何も知らず、カレントディレクトリ内の正規ファイルを検索しようとします。

rar://<url encoded archive name>[*][#[<url encoded entry name>]] 

などの形式に従ってrar://プロトコルラッパーを使用できます。

echo file_get_contents('rar://' . $file . '#' . $entry->getName()); 
関連する問題