downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ZipArchive::getStatusString> <ZipArchive::getFromName
[edit] Last updated: Fri, 25 May 2012

view this page in

ZipArchive::getNameIndex

(PHP 5 >= 5.2.0, PECL zip >= 1.5.0)

ZipArchive::getNameIndexRetourne le nom d'une entrée en utilisant son index

Description

string ZipArchive::getNameIndex ( int $index [, int $flags ] )

Retourne le nom d'une entrée en utilisant son index.

Liste de paramètres

index

Index de l'entrée

flags

Si ce paramètre est défini à ZIPARCHIVE::FL_UNCHANGED, le nom original non modifié sera retourné.

Valeurs de retour

Retourne le nom en cas de succès ou FALSE si une erreur survient.

Exemples

Exemple #1 Exemple avec getnameindex()

<?php
if ($zip->open('test.zip') == TRUE) {
 for (
$i 0$i $zip->numFiles$i++) {
     
$filename $zip->getNameIndex($i);
     
// ...
 
}
}
?>



add a note add a note User Contributed Notes ZipArchive::getNameIndex
Yeslifer 03-Mar-2009 01:13
I couldn't find any how-to example for getting the filenames, so I made an easy one.

Here's an example how to list all filenames from a zip-archive:

<?php
$zip
= new ZipArchive;
if (
$zip->open('items.zip'))
{
     for(
$i = 0; $i < $zip->numFiles; $i++)
     {  
          echo
'Filename: ' . $zip->getNameIndex($i) . '<br />';
     }
}
else
{
     echo
'Error reading zip-archive!';
}
?>

Hope it helps.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites