I am trying to convert a 2 byte string into a Short/int data type with unpack but it does not seem to work:
$str = "\x01\xBB";
unpack("S",$str);
it gives 47873 where as it must return 443
You need to use n
as the format string instead.
$str = "\x01\xBB";
unpack("n",$str);
Look here for more format options.
http://php.net/manual/en/function.pack.php
S
when your string seemingly requires big-endian unpacking?'n'
php.net/manual/en/function.pack.php