downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  

<rar_entry_getRar::getAttr>
Last updated: Thu, 26 Jun 2008

Rar::extract

(No version information available, might be only in CVS)

Rar::extract — Extract entry from the archive

Description

Rar
bool extract ( string $dir [, string $filepath ] )

Rar::extract() extracts entry's data to the dir . It will create new file in the specified dir with the name identical to the entry's name.

Parameters

dir

Path to the directory where files should be extracted.

filepath

If parameter filepath is specified instead dir , Rar::extract() will extract entry's data to the specified file.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Rar::extract() example

<?php

$rar_file
= rar_open('example.rar') or die("Failed to open Rar archive");

$entry = rar_entry_get($rar_file, 'Dir/file.txt') or die("Failed to find such entry");

$entry->extract('/dir/to'); // create /dir/to/Dir/file.txt
$entry->extract(false, '/dir/to/new_name.txt'); // create /dir/to/new_name.txt

?>

Example #2 How to extract all files in archive:

<?php

/* example by Erik Jenssen aka erix */

$filename = "foobar.rar";
$filepath = "/home/foo/bar/";

$rar_file = rar_open($filepath.$filename);
$list = rar_list($rar_file);
foreach(
$list as $file) {
  
$entry = rar_entry_get($rar_file, $file);
  
$entry->extract("."); // extract to the current dir
}
rar_close($rar_file);

?>



add a noteadd a note User Contributed Notes
Extract entry from the archive
There are no user contributed notes for this page.




<rar_entry_getRar::getAttr>
Last updated: Thu, 26 Jun 2008
show source | credits | sitemap | contact | advertising | mirror sites
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://phpbuilder.com/
Last updated: Tue Nov 1 20:20:59 2005 EST
Columns / Articles | Tips / Quickies | News | News Linking and RSS Feeds | Shared Code Library
Mail Archives | Support / Discussion Forums | Get Started! Links | Contribute! | Docs