ZipArchive - List files in the archive


I’m trying to get a list of the files contained in a zip archive, and it is not immediately apparent how to do this. I can see the values of the [name] element with:
$zip = new ZipArchive();
$file = ‘/some/’;
$numfiles = $zip->numFiles;
…but I’m not interested in dumping the raw array out; only accessing the [name] element. I had thought that this would be done with [php]$foo = $zip->statIndex($i)[name];[/php] or [php]$foo = $zip->statIndex($i)[‘name’];[/php] but PHP just complains about an unexpected ‘[’.
Can anyone nudge me in the right direction?

Since this is a function call, you can not just append index to this expression to access array element. But, since this function returns an array, you can do the following:

[php]$arr = $zip->statIndex($i);
$foo = $arr[‘name’];

Sponsor our Newsletter | Privacy Policy | Terms of Service