I did a little research on how to create a TAR archive using php. Although this isn't supported by a PHP extension, there's a pear package that does that just fine, called Archive_Tar.
The whole code to tar and gzip several files is here:
Code:
<?php
// include class
require("Archive/Tar.php");
// create Archive_Tar() object
// specify filename for output file
$tar = new Archive_Tar("data.tar.gz", "gz");
// set up file list
$files = array("images/blank.gif", "images/close.gif", "images/closelabel.gif", "images/thumb-1.jpg");
// build archive
$tar->create($files) or die("Could not create archive!");
?>