Reputation: 69
I need help converting numbers (string) to int8 or uint8 using PHP.
Example: number 10
should be 0A
How can I do this?
Upvotes: 1
Views: 1689
Reputation: 157967
You can use the following line to convert a number to its hexdecimal string representation
echo dechex(intval("10"));
There is also a Hexdump function available for php. This may help too.
You'll find more info here
Upvotes: 0
Reputation: 19466
What it seems like you want to do has nothing to do with signed or unsigned integers, you're just converting an integer to its hexadecimal representation. In PHP, that can be done with dechex
.
dechex(10)
will return 0xA.
Upvotes: 2