Unpack data from binary string
Syntax
unpack ( string $format , string $data [, int $offset = 0 ] ) : array
Parameters
format
See pack() for an explanation of the format codes.
data
The packed data.
offset
The offset to begin unpacking from.
Return
Returns an associative array containing unpacked elements of binary string.
Examples
1
<? $format = "cchars/nint"; $data = "\x04\x00\xa0\x00"; $return = unpack($format, $data); print_r($return); ?>
Array ( [chars] => 4 [int] => 160 )
2
<? $format = "c2chars/nint"; $data = "\x04\x00\xa0\x00"; $return = unpack($format, $data); print_r($return); ?>
Array ( [chars1] => 4 [chars2] => 0 [int] => 40960 )