2) { //// print_r($binaryString); //// echo 1; //// die(print_r($data, 1)); // } if (strlen($binaryString) - $position > 10) { $data['subpacket'] = []; $decoded = decodeString(substr($binaryString, $position), $offset + $position); if ($data['maxoffset'] < $decoded['maxoffset']) { $data['maxoffset'] = $decoded['maxoffset']; } $data['subpacket'][] = $decoded; } } else { $data['lengthTypeId'] = bindec(substr($binaryString, 6, 1)); echo str_repeat(' ', $offset + 6) . substr($binaryString, 6, 1) . "\n"; if ($data['lengthTypeId']) { $data['numberOfPackets'] = bindec(substr($binaryString, 7, 11)); echo str_repeat(' ', $offset + 7) . substr($binaryString, 7, 11) . "\n"; $bin = substr($binaryString, 18); $data['subpacket'] = []; // if ($nesting > 2) { //// print_r($binaryString); //// echo 2; //// die(print_r($data, 1)); // } for ($i = 0; $i < $data['numberOfPackets']; $i++) { $decoded = decodeString($bin, $offset + 18); if ($data['maxoffset'] < $decoded['maxoffset']) { $data['maxoffset'] = $decoded['maxoffset']; $offset = $data['maxoffset']-18; } $data['subpacket'][] = $decoded; $bin = substr($bin, $data['maxoffset']); } // $data['subpacket'][] = decodeString($bin, $offset + 18); } else { $data['totalLengthOfPackets'] = bindec(substr($binaryString, 7, 15)); $bin = substr($binaryString, 22, $data['totalLengthOfPackets']); echo str_repeat(' ', $offset + 7) . substr($binaryString, 7, 15) . "\n"; $data['subpacket'] = []; // if ($nesting > 2) { //// echo 3; //// die(print_r($data, 1)); // } $decoded = decodeString($bin, $offset + 22); if ($data['maxoffset'] < $decoded['maxoffset']) { $data['maxoffset'] = $decoded['maxoffset']; } $data['subpacket'][] = $decoded; } } return $data; } //echo chr(bindec('01010000001')); //8A004A801A8002F478 represents an operator packet // (version 4) which contains an operator packet // (version 1) which contains an operator packet // (version 5) which contains a literal value // (version 6); this packet has a version sum of 16.