php - View content inside phar created archives -
i have .tar.gz, .tar.bzip2 , .tar files, , display contents. since created them phar, make sense try , view them trough phar, tried few things.
first tried php examples
$p = new phar($myarchive[0], 0); // phar extends spl's directoryiterator class foreach (new recursiveiteratoriterator($p) $file) { // $file pharfileinfo class, , inherits splfileinfo echo $file->getfilename() . "\n"; echo file_get_contents($file->getpathname()) . "\n"; // display contents; }
it didn't work.
$fh = new recursiveiteratoriterator(newrecursivedirectoryiterator('phar://'.$myarchive[0]), recursiveiteratoriterator::child_first); foreach ($fh $splfileinfo){ echo file_get_contents($splfileinfo->getpathname()); }
did not work.
i tried
$p = new phardata($myarchive[0]); foreach($p $file) { echo "$file"; }
which strangely seems produce results output tar file strange: phar://c:/zend/apache2/htdocs/application/archives/shaddox/shaddox-1433274964.tar/c:
.tar.gz output same, except appended .gz @ end.
so coorect way view content of .tar , .tar.gz , .tar.bzip2 files phar?
note : $myarchive[0]
contains absolute path archive , works fine using zip library.
Comments
Post a Comment