RarArchive::getEntries

rar_list

(PECL rar >= 2.0.0)

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

說明

面向?qū)ο箫L(fēng)格 (method):

public RarArchive::getEntries(): array|false

過程化風(fēng)格:

rar_list(RarArchive $rarfile): array|false

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

注意:

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).

參數(shù)

rarfile

A RarArchive object, opened with rar_open().

返回值

rar_list() returns array of RarEntry objects 或者在失敗時(shí)返回 false.

更新日志

版本 說明
PECL rar 3.0.0 Support for RAR archives with repeated entry names is no longer defective.

范例

示例 #1 面向?qū)ο箫L(fēng)格

<?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 not 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)

示例 #2 過程化風(fēng)格

<?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);
?>

參見