NYCPHP Meetup

NYPHP.org

[nycphp-talk] next() for multidimensional arrays?

David Krings ramons at gmx.net
Thu May 3 21:19:30 EDT 2007


Che Hodgins wrote:
> Hi David, see below.
> 
> On 5/2/07, David Krings <ramons at gmx.net> wrote:
>> Hi!
>>
>> Is there anything available like next() that will work on
>> multidimensional arrays?

First of all, thanks for pointing out my brain fart with using the same 
key for different values.
Second, what I tried to do is use again the hammer and consider 
everything a nail. I upload a ZIP (!!!) archive, extract it, throw the 
zip file away, and now break my neck to find out what the files and 
folders are! *slaphandonhead*
This:
$zip = zip_open($localzipfile);
if ($zip) {
     while ($zip_entry = zip_read($zip)) {
         echo "Name:               " . zip_entry_name($zip_entry) . "<br 
/>";
         echo "Actual Filesize:    " . zip_entry_filesize($zip_entry) . 
"<br />";
         echo "<br />";
     }
     zip_close($zip);
}

does the trick. If the filesize is 0 then it is either just a folder 
entry or a file that I don't want anyway. So anything with a file size 
bigger than 0 will go into my array, with path and file name.
What really threw me off is that zip_open() does not work with relative 
path/file names. Something like ./dir/zip file.zip returns an integer 
and not a resource handle! After translating the relative path into a 
direct path all things went smoothly.

OK, I keep hammering away then.

David




More information about the talk mailing list