I'm trying to convert hex code from 010 Editor to int. 010 Editor
How can I get 4118 by converting string 16100000? I tried hexdec function, but It gives the wrong result.
echo hexdec('1610'); //gives 5648
echo hexdec('16100000'); //gives 370147328
And how to convert back 4118 to 16100000?
That hex to int32 convertion in the 010 Editor you've mentioned has little endian sequencing ( https://en.wikipedia.org/wiki/Endianness ).
So, you have to assemble your original hexadecimal string in inverse order.
echo hexdec('00001016'); // Would result in the 4118 you were expecting.
And to have it back you can use base_convert, from base 10 to base 16 and rearenge the string:
echo base_convert('00004118', 10, 16);
Which would give you '1016'
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.