Corbie Posted October 1, 2007 Share Posted October 1, 2007 Hi, I'm very new to PHP only days old so if this seems like a silly question I apologzie. I have a file duplication progam I wrote years ago in C on a Unix system. I open up zip files and store CRC info in my own database. It's a great application for php/mysql and I would like to learn php/mysql in the process of moving it over. Can someone tell me how you would read the header (data structure information with all the fields) on a zip file (in this case its the localheader right after the signature), so that all the fields of the structure land nicely in an array in php? I'm attempting to use freads/fseek to each field and this just can't be right. Doesn't matter what data structure I just need to know the most common method you use to open a file in read blocks of data and unpack them back into a data structure. Many Thanks Quote Link to comment https://forums.phpfreaks.com/topic/71348-reading-c-data-structures-with-php/ Share on other sites More sharing options...
trq Posted October 1, 2007 Share Posted October 1, 2007 'm attempting to use freads/fseek to each field and this just can't be right. What makes you think so? I just need to know the most common method you use to open a file in read blocks of data and unpack them back into a data structure. fread. Quote Link to comment https://forums.phpfreaks.com/topic/71348-reading-c-data-structures-with-php/#findComment-359002 Share on other sites More sharing options...
Corbie Posted October 1, 2007 Author Share Posted October 1, 2007 Maybe I a missing something. If I was reading this in C I would do a single fread to a data structure then can immediately use any field with Name.Field. I can also read that entire data stucture with an fread in php but how do you unpack to an array or access each field? Guess that is where I'm stuck. Quote Link to comment https://forums.phpfreaks.com/topic/71348-reading-c-data-structures-with-php/#findComment-359009 Share on other sites More sharing options...
trq Posted October 1, 2007 Share Posted October 1, 2007 Yeah, I guess I'm a little lost as to exactly what your trying to do. I really only know a little C basics. You can read an entire file into an array using file where each key is a line in the file. Otherwise, you might have some luck with the zip extension. Quote Link to comment https://forums.phpfreaks.com/topic/71348-reading-c-data-structures-with-php/#findComment-359011 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.