unpack

WMMEGA FW >= 2.1167

unpack — Unpack data from binary string

Description

mixed unpack ( string $format, binary string $value )

Unpacks from a binary string into an array according to the given format.

Parameters

$format: String containing one of the following values:

Value Description
l signed long (always 32 bit, machine byte order)
L unsigned long (always 32 bit, machine byte order)
f floating point(always 32 bit, machine byte order)
c signed byte
C unsigned byte

$value: Value is a binary string passed by reference (&).

Return Values

mixed: Unpacked value from binary string

Example

<?
  v=-1234;
  $str=pack("l",$v);
  print("\r\nPacked signed long:\r\n");
  for ($i=0;$i<4;$i++) {
    $c=charat($str,$i);
    printf("%02X ",$c);
  }
 
 
  print("\r\nUn packed signed long:\r\n");
  $v=unpack("l",&$str);  // <--- Note the & symbol - this needs to be passed by reference.
 
  print($v);
?>

See Also

pack() - Pack a binary string