note 77129 deleted from function.zip-entry-read by nlopess

From: Date: Wed, 05 Dec 2007 20:27:01 +0000
Subject: note 77129 deleted from function.zip-entry-read by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-132861@lists.php.net to get a copy of this message
Note Submitter: Radon8472 ---- Ive got a big Problem with the "zip_entry_read" function, and I dont unterstand what I did wrong. I tried to write a function, wicht reads all zip Entries of a file into an Array. It worked, I can read alle Methadata from this array. But when i try to read the content, I always get nothing. This is an example whre you can see whats the problem: when I read 10 Bytes content IN the funktion, it works, but when I try the same with the returnvalue (or with the refference of the entries), it won`t work. With the result of the function, I can also read all the methadata (filename, size ...) but only the Content, seems to be emty after the function. <?php require("zip_funct.inc.php"); function test(&$zip_entry = null) { $zip = zip_open("test.zip"); while( $tmp[] = zip_read($zip) ); array_pop($tmp); $zip_entry = $tmp; $n = 2; var_dump($zip_entry); $buf = zip_entry_read($zip_entry[$n], 10); echo "CONTENT:\n------------------\n".$buf."\n"; echo "------------------\n"; echo "Name: " . zip_entry_name($zip_entry[$n]) . "\n"; echo "Actual Filesize: " . zip_entry_filesize($zip_entry[$n]) . "\n"; echo "Compressed Size: " . zip_entry_compressedsize($zip_entry[$n]) . "\n"; echo "Compression Method: " . zip_entry_compressionmethod($zip_entry[$n]) . "\n"; // echo fread($result, 50); return $zip_entry; } // ################################################## // test($zip_entry); // try to get the zip_entries via Refference $zip_entry = test(); // try to get zip_entries s return value $n = 2; var_dump($zip_entry); $buf = zip_entry_read($zip_entry[$n], 10); echo "CONTENT:\n------------------\n".$buf."\n"; echo "------------------\n"; echo "Name: " . zip_entry_name($zip_entry[$n]) . "\n"; echo "Actual Filesize: " . zip_entry_filesize($zip_entry[$n]) . "\n"; echo "Compressed Size: " . zip_entry_compressedsize($zip_entry[$n]) . "\n"; echo "Compression Method: " . zip_entry_compressionmethod($zip_entry[$n]) . "\n"; ?> The screenoutput looks like this: array(8) { [0]=> resource(61) of type (Zip Entry) [1]=> resource(62) of type (Zip Entry) // and a lot other entries } CONTENT: ------------------ <html> <h ------------------ Name: tmp.html Actual Filesize: 1136 Compressed Size: 360 Compression Method: deflated array(8) { [0]=> resource(61) of type (Zip Entry) [1]=> resource(62) of type (Zip Entry) // and a lot other entries } CONTENT: ------------------ ------------------ Name: tmp.html Actual Filesize: 1136 Compressed Size: 360 Compression Method: deflated And this output shows, that the returnvalue of the function still as a valid ressource and still returns the correct methadata, but the content is empty. I try to solve this problem since weeks and I realy need help. If anybody has an idea whats the Problem, please notice hear.

« previous php.notes (#132861) next »