note 89314 modified in function.ziparchive-getnameindex by thiago

From: Date: Tue, 03 Mar 2009 13:45:25 +0000
Subject: note 89314 modified in function.ziparchive-getnameindex by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151391@lists.php.net to get a copy of this message
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. --was-- 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. http://php.net/manual/en/function.ziparchive-getnameindex.php

« previous php.notes (#151391) next »