O'Reilly logo

Programming PHP, 3rd Edition by Peter MacIntyre, Kevin Tatroe, Rasmus Lerdorf

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

pack

Synopsis

string pack(string format, mixed arg1[, mixed arg2[, ... mixed argN]])

Creates a binary string containing packed versions of the given arguments according to format. Each character may be followed by a number of arguments to use in that format, or an asterisk (*), which uses all arguments to the end of the input data. If no repeater argument is specified, a single argument is used for the format character. The following characters are meaningful in the format string:

a

NUL-byte-padded string

A

Space-padded string

h

Hexadecimal string, with the low nibble first

H

Hexadecimal string, with the high nibble first

c

Signed char

C

Unsigned char

s

16-bit, machine-dependent byte-ordered signed short

S

16-bit, machine-dependent byte-ordered unsigned short

n

16-bit, big-endian byte-ordered unsigned short

v

16-bit, little-endian byte-ordered unsigned short

i

Machine-dependent size and byte-ordered signed integer

I

Machine-dependent size and byte-ordered unsigned integer

l

32-bit, machine-dependent byte-ordered signed long

L

32-bit, machine-dependent byte-ordered unsigned long

N

32-bit, big-endian byte-ordered unsigned long

V

32-bit, little-endian byte-ordered unsigned long

f

Float in machine-dependent size and representation

d

Double in machine-dependent size and representation

x

NUL-byte

X

Back up one byte

@

Fill to absolute position (given by the repeater argument) with NUL-bytes

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required