Link to home
Start Free TrialLog in
Avatar of aspegicus
aspegicus

asked on

php binary file writing with pack() function : need to inverse byte order !

I have an issue writting binary files in php. I need to write the following 4 bytes Hex codes in a file (on intel) : 1000 2E00 0068 7474 703A

I do : pack('H*','10002E0000687474703A') and expect to have same in my binary file doing an hexdump but I get instead 0010 002E 6800 7474 3A70

What can I do to reverse those bytes?
Avatar of ravenpl
ravenpl
Flag of Poland image

from doc:
h Hex string, low nibble first
H Hex string, high nibble first

Why will not You try lower H then?
Avatar of aspegicus
aspegicus

ASKER

Simply because pack('h*','10002E0000687474703A') writes 0001 00e2 8600 4747 a307 not what I need..
ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Right on! It was hexdump on linux that is displaying the sequence of bytes in reverse order compared to xvi32 under Windows. I'm all set.