Jump to content

Reading C Data Structures with PHP


Corbie

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/71348-reading-c-data-structures-with-php/
Share on other sites

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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.