Given a binary string. Every 4 characters in it have one float value in big-endian format.
$binary_data; // здесь бинарные данные $data_num = 3800; // целое значение - сколько байт данных $bts_float = 4; // 4 символа на значение for ($i = 0; $i < $data_num/$bts_float; $i++) { $tmpbuffer = ''; $index=$i*$bts_float; $tmpbuffer .= $binary_data[$index+3]; $tmpbuffer .= $binary_data[$index+2]; $tmpbuffer .= $binary_data[$index+1]; $tmpbuffer .= $binary_data[$index]; array_push($result_array, unpack("f", $tmpbuffer)); } While unpack("G*", $buffer); at least somehow tolerantly discloses, but this is only for PHP 7.0+, and for 5.6 only with the approximate code above.
Error: {"1": - 77.17456817626953}, {"1": - 77.43785858154297}, {"1": - 79.72053527832031} ...
Question: Is it okay with the code? Where did "1" come from?
in Python, it is unpacked like this: struct.unpack('!%df' % block, buffer) , where block = number of values / 4, buffer - binary data