Is it possible to get a subsection of a hex value? For example:
0x7dd becomes 0xdd
$hex = 0x7dd;
$bin = hex2bin($hex);
$ bin = substr($bin,4); //so it excludes the four most significant bits ie. the most significant hex digit
Please read on bitwise operators.
Applying &
(bitwise and) on a mask, or >>
(right-shift) could be what your looking for (without converting back and forth to string
).
For example:
0x7dd & 0xff == 0xdd
where & 0xff
essentially ignores everything except the last two hex digits