could someone help me get this data into the PHP equivalent: >4siiiiiiiiiiiii8x
It is used in struct.pack()
in Python. this is what i got so far: N14si13x8
it's supposed to be returning: ('P3TF', 272, 64, 6832, 6896, 1426, 8336, 312, 8656, 0, 8656, 0, 8656, 2924384)
The PHP version results:
array
'si13x81' => int 1345541190
'si13x82' => int 272
'si13x83' => int 64
'si13x84' => int 6832
'si13x85' => int 6896
'si13x86' => int 1426
'si13x87' => int 8336
'si13x88' => int 312
'si13x89' => int 8656
'si13x810' => int 0
'si13x811' => int 8656
'si13x812' => int 0
'si13x813' => int 8656
'si13x814' => int 2924384
still need to get the first one right.
I guess the main problem is that i
and s
have different meaning in PHP. To recreate your original list in PHP this seems to work:
print_r(unpack("a4header/N13int/x8fill", $p));
Gives me:
Array(
[header] => P3TF
[int1] => 272
[int2] => 64
[int3] => 6832
[int4] => 6896
[int5] => 1426
[int6] => 8336
[int7] => 312
[int8] => 8656
[int9] => 0
[int10] => 8656
[int11] => 0
[int12] => 8656
[int13] => 2924384
I'm not so sure about the x8
. That's not used for padding in PHP. Maybe try @
if it doesn't work on a real datafile.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.