Skip to content

Instantly share code, notes, and snippets.

@erdum
Created January 13, 2024 09:27
Show Gist options
  • Save erdum/ca8c6617639f80bd9bd60da6547bb786 to your computer and use it in GitHub Desktop.
Save erdum/ca8c6617639f80bd9bd60da6547bb786 to your computer and use it in GitHub Desktop.
Extract tar file with PHP
<?php
$tarFile = __DIR__ . '/file.tar';
$extractTo = __DIR__ . '/';
exec("tar -xf $tarFile -C $extractTo", $output, $returnCode);
if ($returnCode === 0) {
echo 'Extraction successful!';
} else {
echo 'Extraction failed!';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment