Quantcast
Channel: Php Snippets Archives - BinaryTides
Viewing all articles
Browse latest Browse all 20

How to extract tar.gz archives in php

$
0
0
In a previous article we learned how to . Now lets do the reverse, that is extract tar.gz archives and get the files out.
The code to extract a tar.gz archive is very simple and uses PharData class. Here is an example


// decompress from gz
$p = new PharData('files.tar.gz');
$p->decompress(); // creates files.tar

// unarchive from the tar
$phar = new PharData('files.tar');
$phar->extractTo('new_dir');


The first step is to uncompress the tar.gz and convert into a .tar file. Next the .tar file is unpacked and file are copied inside a directory.
Last Updated On : 12th March 2013...

Read full post here
How to extract tar.gz archives in php


Viewing all articles
Browse latest Browse all 20

Trending Articles