PHP unpack() Function

The unpack() function unpacks data from a binary string.

array unpack ( string $format , string $data [, int $offset = 0 ] )

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

The unpacked data is stored in an associative array. To accomplish this you have to name the different format codes and separate them by a slash /. If a repeater argument is present, then each of the array keys will have a sequence number behind the given name.

Example -

ParameterDescription
formatSee pack() for an explanation of the format codes.
dataThe packed data.
offsetThe offset to begin unpacking from.

Return Values

Returns an associative array containing unpacked elements of binary string.