update : 2015.11.03
php.shukuma.com

검색:
 
 
Get full list of entries from the RAR archive

RarArchive::getEntries

rar_list

(PECL rar >= 2.0.0)

RarArchive::getEntries -- rar_listGet full list of entries from the RAR archive

설명

객체 기반 형식 (method):

public array RarArchive::getEntries ( void )

절차식 형식:

array rar_list ( RarArchive $rarfile )

Get entries list (files and directories) from the RAR archive.

Note:

If the archive has entries with the same name, this method, together with RarArchive foreach iteration and array-like access with numeric indexes, are the only ones to access all the entries (i.e., RarArchive::getEntry() and the rar:// wrapper are insufficient).

인수

rarfile

A RarArchive object, opened with rar_open().

반환값

rar_list() returns array of RarEntry objects 실패 시 FALSE를 반환합니다.

변경점

버전 설명
3.0.0 Support for RAR archives with repeated entry names is no longer defective.

예제

Example #1 객체 기반 형식

<?php
$rar_arch 
RarArchive::open('solid.rar');
if (
$rar_arch === FALSE)
    die(
"Could not open RAR archive.");

$rar_entries $rar_arch->getEntries();
if (
$rar_entries === FALSE)
    die(
"Could retrieve entries.");

echo 
"Found " count($rar_entries) . " entries.\n";

foreach (
$rar_entries as $e) {
    echo 
$e;
    echo 
"\n";
}
$rar_arch->close();
?>

위 예제의 출력 예시:

Found 2 entries.
RarEntry for file "tese.txt" (23b93a7a)
RarEntry for file "unrardll.txt" (2ed64b6e)

Example #2 절차식 형식

<?php
$rar_arch 
rar_open('solid.rar');
if (
$rar_arch === FALSE)
    die(
"Could not open RAR archive.");

$rar_entries rar_list($rar_arch);
if (
$rar_entries === FALSE)
    die(
"Could retrieve entries.");

echo 
"Found " count($rar_entries) . " entries.\n";

foreach (
$rar_entries as $e) {
    echo 
$e;
    echo 
"\n";
}
rar_close($rar_arch);
?>

참고