473,473 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

zip_read strangeness

Hi!

I'm using the zip functions for the first time and I'm having an odd
problem. I may be doing something boneheaded, here's hoping someone
here can recognize it.

I have a foreach loop that goes through a list of files and is supposed
to generate a list of the contents.

foreach($filelist as $filename)
{
if (($temp = zip_open($local_storage.$filename)))
{
while ($entry = zip_read($temp))
{
$file_name = zip_entry_name($entry);
$file_size = zip_entry_filesize($entry);
$compression = zip_entry_compressionmethod($entry);

echo "Contains: $file_name ($file_size) compressed with
$compression.\n";

//Do stuff
}
zip_close($temp);
}
}

It appears to work, but when I look at the output, I realize that the
info is correct for the _first_ file it iterates through, but each
subsequent file is just showing the same data from the first file
again. I've verified that the zip contents are different. I've tried
manually clearing the strings involved, played around with
zip_open_entry, and so on, but it keeps repeating the info from the
first zip as the data for the rest.

It's late here, maybe I'm missing something obvious. Can anyone tell
me why it might behave like this?

Thanks!

Jan 10 '07 #1
3 1364
Tried your script and it works fine, though at first it wasn't working
because i had relative paths in filenames...

Jan 10 '07 #2
zorro wrote:
Tried your script and it works fine, though at first it wasn't working
because i had relative paths in filenames...
Hmm, if the logic is ok, maybe something is weird with my environment.
Thanks!

Jan 10 '07 #3
(forehead slap)

I just figured it out.

I had trimmed the foreach loop from my original code snippet when I put
it in, then, realizing it would help make it readable, I put it back.
....but instead of putting it back intact, I just retyped it from
memory. It turns out that my foreach loop pushed out a different
variable name, but the $filename string I was using was leftover from a
few lines before.

So, local namespace variables might havesaved my from my own stupidity.
The code works when I actually pass it a variable name that changes.
Whooops....

On the plus side, there's code on Google Groups showing how to read out
the contents of a zip from PHP now, heh.

Regards,

Ben

Jan 10 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robin Becker | last post by:
We had some legacy applications that used import to get parts of documents in. When run separately these worked fine, but failed when run as a single process because they both imported ch1 (after...
1
by: Miki Tebeka | last post by:
Hello All, Can you explain why: - adp86: python -c 'import sys; print 1' 1 - adp86: python -c 'for i in range(3): print i' 0 1 2 - adp86: python -c 'import sys; for i in range(3): print...
8
by: Stefan Seefeld | last post by:
hi there, I have trouble running some python code with 'exec': t.py contains: class Foo: pass class Bar: f = Foo From a python shell I do:
5
by: dark.ryder | last post by:
I must be doing something wrong, but for the life of me, I can't figure out what. Here's the code snippet which is giving me grief: print type(number), type(name), type(seconds // 60),...
2
by: Munnki | last post by:
I am learning Perl and was using the Wrox Learning Perl book that I found on the web. The author was explaining the autoincrement operator and try as I might I can't understand this behaviour. The...
2
by: Robert M. Gary | last post by:
I'm using JRE 1.5 on Solaris Japanese (Sparc). The JVM claims its default character set is EUC-JP I'm seeing two strange things when using Japanese character sets... 1) If I write a program that...
3
by: Mark Carroll | last post by:
Trying this in Firefox: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;...
3
by: Tom | last post by:
http://braintech.net.au:8000/question/play.zip only 57 kb hi friends I'm struggling with this very simple sample remoting application. What I am doing is simply testing remoting but when I...
2
by: Glen Able | last post by:
The behaviour of << and >> arithmetic operators (under VC++6, x86) seems rather odd to me. Shifts at runtime seem to only use the bottom 5 bits of the shift amount (an x86 issue I suppose), but...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.