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? Quote 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'); Quote 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. Quote 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") { Quote 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? Quote 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 '"'). Quote 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 "<, >, ?" ? Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.