fork download
  1. <?php
  2.  
  3. $binary = "\x00\x00\x12\x56\x41\xab\x32\xde"; // musisz wyrównać zerami dane do wielokrotności 32 bitów
  4. $decoded = unpack("N*", $binary);
  5.  
  6. // w $decoded masz teraz tablice dwoch longow 32 bitowych unsigned big-endian
  7. // $decoded[1] = 0x00001256;
  8. // $decoded[2] = 0x41ab32de;
  9.  
  10. $a = $decoded[1];
  11. $b = ($a & 0xfff0) >> 4;
  12.  
  13. echo $b . ' (0x'.dechex($b) . ')'; // 293 (0x125)
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
293 (0x125)