I am writting a programm to decode a binary file. I am currently in test phase and I use phpunit. I tried to assign a two byte value into a variable but the value changed without any apparent reason. I get 132 instead of 1.
The original bytes of the file are : 00 0F 00 01
Here is the code who decodes this part :
$infos = unpack('n2', fread($file, 4));
print_r($infos);
print($infos[2]);
$nb = $infos[2];
print(' nb '.$nb);
here is the result in the console :
Array
(
[1] => 15
[2] => 1
)
1 nb 132
The contents of $infos are completely fine, but I don’t understand why $nb takes the value 132.