So i’m making a class in PHP to parse the VPK file format.
However i’ve hit a problem:
object(VPKHeader)#2 (3) {
["Signature"]=>
string(8) "3412aa55"
["Version"]=>
string(4) "1000"
["DirectoryLength"]=>
int(832512)
}
The signature is supposed to be 0x55aa1234, however the signature I’m reading is 0x3412aa55.
How do I switch the endianness in PHP?
If your hex values will always be strings, you can use the following function :
Agreed, it’s not the most efficient, but the code is quite elegant in my opinion. Also, it works with all sizes of numbers.