DWORD to Character Array
Posted: Wed Mar 11, 2009 9:31 am
Hello everyone,
I want to convert a 32bit Integer (or DWORD) into a chr array with a length of 4 chrs. I've tried using bitwise:
...but it only seems to work for certain number ranges, so I'm assuming I've messed up somewhere. Can anyone offer me some assistance here?
Regard,
Kip.
I want to convert a 32bit Integer (or DWORD) into a chr array with a length of 4 chrs. I've tried using bitwise:
Code: Select all
function dword2chrs($num)
{
$result = "";
for ($x = 3; $x > -1; $x--)
$result .= chr(($num >> (8 * $x)) & 255);
return $result;
}
Regard,
Kip.