❮ Tham chiếu khác PHP
Thí dụ
Giải nén dữ liệu từ một chuỗi nhị phân:
Định nghĩa và Cách sử dụng
Hàm unpack [] giải nén dữ liệu từ một chuỗi nhị phân.
Cú pháp
Giá trị tham
số
ParameterDescription
format
| Required. Specifies the format to use when unpacking data. Possible values: - a - NUL-padded string
- A - SPACE-padded string
- h - Hex string, low nibble first
- H - Hex string, high nibble first
- c - signed char
- C - unsigned char
- s - signed short [always 16 bit, machine byte order]
- S - unsigned short [always 16 bit, machine byte order]
- n - unsigned short [always 16 bit, big endian byte order]
- v - unsigned
short [always 16 bit, little endian byte order]
- i - signed integer [machine dependent size and byte order]
- I - unsigned integer [machine dependent size and byte order]
- l - signed long [always 32 bit, machine byte order]
- L - unsigned long [always 32 bit, machine byte order]
- N - unsigned long [always 32 bit, big endian byte order]
- V - unsigned long [always 32 bit, little endian byte order]
- q - signed long long [always 64 bit, machine byte
order]
- Q - unsigned long long [always 64 bit, machine byte order]
- J - unsigned long long [always 64 bit, big endian byte order]
- P - unsigned long long [always 64 bit, little endian byte order]
- f - float [machine dependent size and representation]
- g - float [machine dependent size, little endian byte order]
- G - float [machine dependent size, big endian byte order]
- d - double [machine dependent size and representation]
- e - double
[machine dependent size, little endian byte order]
- E - double [machine dependent size, big endian byte order]
- x - NUL byte
- X - Back up one byte
- Z - NUL-padded string
- @ - NUL-fill to absolute
|
data
| Required. Specifies the binary data to be unpacked
|
offset
| Optional. Specifies where to start unpacking from. Default is 0.
|
Chi tiết kỹ thuật
Giá trị trả lại:Trả về một mảng khi thành công hoặc FALSE nếu không thành công.
|
Phiên bản PHP:4+
|
Changelog:PHP 7.2 - float và double hiện hỗ trợ cả endian lớn và nhỏ. PHP 7.1 - Đã thêm tham số bù đắp tùy chọn. PHP 5.5.0 - Các thay đổi sau được thực hiện để tương thích với Perl: Mã "a" hiện giữ lại các byte NULL theo sau. Mã "A" bây giờ loại bỏ tất cả khoảng trắng ASCII theo sau. Mã "Z" đã được thêm cho các
chuỗi có đệm NULL và xóa các byte NULL ở cuối.
|
Các ví dụ khác
Thí dụ
Giải nén dữ liệu:
Thí dụ
Giải nén dữ liệu:
❮ Tham chiếu khác PHP
❮ Tham chiếu khác PHP
Thí dụ
Giải nén dữ liệu từ một chuỗi nhị phân:
Định nghĩa và Cách sử dụng
Hàm unpack [] giải nén dữ liệu từ một
chuỗi nhị phân.
Cú pháp
Giá trị tham số
ParameterDescription
format
| Required. Specifies the format to use when unpacking data. Possible values: - a - NUL-padded string
- A - SPACE-padded string
- h - Hex string, low nibble first
- H - Hex string, high nibble first
- c - signed char
- C - unsigned char
- s - signed short [always 16 bit, machine byte order]
- S - unsigned short [always 16 bit, machine byte order]
- n - unsigned short [always 16 bit, big endian byte order]
- v - unsigned
short [always 16 bit, little endian byte order]
- i - signed integer [machine dependent size and byte order]
- I - unsigned integer [machine dependent size and byte order]
- l - signed long [always 32 bit, machine byte order]
- L - unsigned long [always 32 bit, machine byte order]
- N - unsigned long [always 32 bit, big endian byte order]
- V - unsigned long [always 32 bit, little endian byte order]
- q - signed long long [always 64 bit, machine byte
order]
- Q - unsigned long long [always 64 bit, machine byte order]
- J - unsigned long long [always 64 bit, big endian byte order]
- P - unsigned long long [always 64 bit, little endian byte order]
- f - float [machine dependent size and representation]
- g - float [machine dependent size, little endian byte order]
- G - float [machine dependent size, big endian byte order]
- d - double [machine dependent size and representation]
- e - double
[machine dependent size, little endian byte order]
- E - double [machine dependent size, big endian byte order]
- x - NUL byte
- X - Back up one byte
- Z - NUL-padded string
- @ - NUL-fill to absolute
|
data
| Required. Specifies the binary data to be unpacked
|
offset
| Optional. Specifies where to start unpacking from. Default is 0.
|
Chi tiết kỹ thuật
Giá trị trả lại:Trả về một mảng khi thành công hoặc FALSE nếu không thành công.
|
Phiên bản PHP:4+
|
Changelog:PHP 7.2 - float và double hiện hỗ trợ cả endian lớn và nhỏ. PHP 7.1 - Đã thêm tham số bù đắp tùy chọn. PHP 5.5.0 - Các thay đổi sau được thực hiện để tương thích với Perl: Mã "a" hiện giữ lại các byte NULL theo sau. Mã "A" bây giờ loại bỏ tất cả khoảng trắng ASCII theo sau. Mã "Z" đã được thêm cho các
chuỗi có đệm NULL và xóa các byte NULL ở cuối.
|
Các ví dụ khác
Thí dụ
Giải nén dữ liệu:
Thí dụ
Giải nén dữ liệu:
❮ Tham chiếu khác PHP