Php how to unpack hexadecimal data
I have this:
0xC1 0x3A 0x00 0x01 0x5D 0xDA 0x47 0x53 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
开发者_运维百科0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00, 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0xF0 0xFC 0x12 0x00 0x00 0x00
struct FileInfo {
unsigned char header;
unsigned char size;
unsigned char type;
unsigned char subtype;
unsigned short item;
char itemName[50];
unsigned short ItemCode;
}
I tried using unpack(), but it was unsuccessful
To unpack everything, you can use the following:
$unpackedData = unpack('cheader/csize/ctype/csubtype/Sitem/c50itemName/SitemCode', $binData);
精彩评论