HI,
other that writing my own function does any one know a quick way of getting a variable that contains hexadecimal data to stay as an integer as opposed to a string ?
When I cast to an int it zeros the values as it has letters, and including 0x at the beginning doesn't seem to alter the outcome.
Thanks in advance
:0)
hexdec() converts a string from hexidecimal to decimal.
Hi Chad,
yeah I di that but all the in built functions that take decimals and convert to hex return them as a string :0( and I need to do maths type stuff, ehn I cast I get 0 or if I am lucky 1.
Thanks for your help though
Yeah,
First use hexdec(), then force it into an integer.
E.g.
$hex_num = "FF"; $dec_num = hexdec($hex_num); $int_num = (int) $dec_num;
$int_num should now be an integer
Cheers! Anwar