Rar Funkcje
PHP Manual

Rar::extract

(PECL rar >= 0.1)

Rar::extractExtract entry from the archive

Opis

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.

Parametry

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.

Zwracane wartości

Zwraca TRUE w przypadku powodzenia, FALSE w przypadku błędu.

Przykłady

Przykład #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

?>

Przykład #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);

?>


Rar Funkcje
PHP Manual