Hi I have a string 193390663 which I want to convert into the hex with 2's compliment. The output is 0B86E847
Right now I am using below function but it's giving me 313933333930363633
public static function String2Hex($string)
{
$hex = '';
for($i=0; $i<strlen($string); $i++)
{
$hex.=dechex(ord($string[$i]));
}
}
Update 1
Tried this
$sub2 = substr($m->msn,4,9);
$m->m_hex = dechex ($sub2);
Output
b86e847
But I want output like 0B86E847
Any help would be highly appreciated.
hex with 2's compliment?