unpack

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
)

__halt_compiler

connection_aborted

connection_status

constant

define

defined

die

eval

exit

highlight_file

highlight_string

hrtime

ignore_user_abort

pack

php_strip_whitespace

show_source

sleep

sys_getloadavg

time_nanosleep

time_sleep_until

uniqid

usleep

PHP

Home Menu