1. Go to this page and download the library: Download mishak/archive-tar library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mishak / archive-tar example snippets
$filename = 'archive.tar';
$reader = new Mishak\ArchiveTar\Reader($filename);
$read->setBuffer(PHP_INT_MAX);
$read->setReadContents(FALSE);
foreach ($reader as $record) {
print_r($record);
}
$filename = 'archive.tar';
$reader = new Mishak\ArchiveTar\Reader($filename);
foreach ($reader as $record) {
if (in_array($record['type'], array(\Mishak\ArchiveTar\Reader::REGULAR, \Mishak\ArchiveTar\Reader::AREGULAR), TRUE)) {
echo $record['filename'], "\n";
echo $record['contents'], "\n";
}
}
$filename = 'archive.tar';
$reader = new Mishak\ArchiveTar\Reader($filename);
$lastRecord = NULL;
$read->setReadContents(function ($record, $chunk, $left, $read) use ($lastRecord) {
if (!in_array($record['type'], array(\Mishak\ArchiveTar\Reader::REGULAR, \Mishak\ArchiveTar\Reader::AREGULAR), TRUE)) {
continue;
}
if (NULL === $lastRecord || $record['filename'] !== $lastRecord['filename']) {
if (NULL !== $lastRecord) {
echo "\n";
}
echo $record['filename'], "\n";
}
echo $chunk;
if (!$left) {
echo "\n";
}
}
});
foreach ($reader as $record) {
// don't mind just walking thru...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.