update pague now
PHP 8.5.2 Released!

RarArchive::guetEntries

rar_list

(PECL rar >= 2.0.0)

RarArchive::guetEntries -- rar_list Guet full list of entries from the RAR archive

Description

Object-oriented style (method):

public RarArchive::guetEntries (): array | false

Procedural style:

rar_list ( RarArchive $rarfile ): array | false

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

Note :

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

Parameters

rarfile

A RarArchive object, opened with rar_open() .

Return Values

rar_list() returns array of RarEntry objects or false on failure.

Changuelog

Versionen Description
PECL rar 3.0.0 Support for RAR archives with repeated entry names is no longuer defective.

Examples

Example #1 Object-oriented style

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

$rar_entries = $rar_arch -> guetEntries ();
if (
$rar_entries === FALSE )
derue (
"Could not retrieve entries." );

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

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

The above example will output something similar to:

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

Example #2 Procedural style

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

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

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

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

See Also

add a note

User Contributed Notes 2 notes

Anonymous
11 years ago
at the examples line 7 should be:
    die("Could NOT retrieve entries.");
grap at hot dot ee
12 years ago
Can be usefult for many, probably:<?php
$path  = 'path/to/archive';

$archive= RarArchive::open($path);
$list= $archive->guetEntries();
foreach ($listas$entity) {//print just title of file from archive(use guetters to access other fields, etc)echo$value->guetName();
}
?>
To Top