Zero3X Posted October 26, 2010 Share Posted October 26, 2010 Basically I need to search through a zip file for one file. I've tried quite a few things but the zip functions are now really starting to annoy me. My most recent attempt was this: $zip = zip_open(myzip.zip); while ($zip_file = zip_read($zip) != "file.php") { } zip_entry_open($zip, $zip_file); $contents = zip_entry_read($zip_file); But of course that just timed out on me. Anyone got any ideas? Link to comment https://forums.phpfreaks.com/topic/216837-search-for-a-file-in-a-zip/ Share on other sites More sharing options...
trq Posted October 26, 2010 Share Posted October 26, 2010 zip_open() expects a string. $zip = zip_open('myzip.zip'); Link to comment https://forums.phpfreaks.com/topic/216837-search-for-a-file-in-a-zip/#findComment-1126462 Share on other sites More sharing options...
Zero3X Posted October 26, 2010 Author Share Posted October 26, 2010 zip_open() expects a string. $zip = zip_open('myzip.zip'); That was a typo It is a string in the actual file. Link to comment https://forums.phpfreaks.com/topic/216837-search-for-a-file-in-a-zip/#findComment-1126703 Share on other sites More sharing options...
BlueSkyIS Posted October 26, 2010 Share Posted October 26, 2010 this is invalid syntax: while ($zip_file = zip_read($zip) != "file.php") { Link to comment https://forums.phpfreaks.com/topic/216837-search-for-a-file-in-a-zip/#findComment-1126712 Share on other sites More sharing options...
PFMaBiSmAd Posted October 26, 2010 Share Posted October 26, 2010 That was a typo When copy/pasting the actual code you are expecting help with, how can there be typo's? Link to comment https://forums.phpfreaks.com/topic/216837-search-for-a-file-in-a-zip/#findComment-1126715 Share on other sites More sharing options...
Zero3X Posted October 26, 2010 Author Share Posted October 26, 2010 That was a typo When copy/pasting the actual code you are expecting help with, how can there be typo's? It was a variable ($thezipfile = "myzip.zip") but it's seperated from the zip check section of the script by unrelated code. So I took the liberty of changing the variable to a string (and forgetting to use '"'). Link to comment https://forums.phpfreaks.com/topic/216837-search-for-a-file-in-a-zip/#findComment-1126729 Share on other sites More sharing options...
Zero3X Posted October 26, 2010 Author Share Posted October 26, 2010 Well, I've managed to get this all working. However, when I echo out the contents of the file it only shows the second line. The complete file <div> Hello - I only get this outputted. <?php function doesnoexist(); ?> </div> Does zip_entry_read not process characters like "<, >, ?" ? Link to comment https://forums.phpfreaks.com/topic/216837-search-for-a-file-in-a-zip/#findComment-1126832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.