unpack
Function • Params and return types changed in PHP 8.0
Unpack data from binary string.
unpack Function synopsis
unpack(
string $format,
string $string,
int $offset = 0
): array|false
Parameters
$format
Typestring
See pack for an explanation of the format codes.
$string
Typestring
The packed data.
$offset
OptionalTypeintDefault value0
The offset to begin unpacking from.
Return value
Typearray|false
Returns an associative array containing unpacked elements of binary
string, or false on failure.
Changes to the unpack Function
PHP 8.0
- Return type added:
array|false - Parameter type added for parameter #1 (
$format):string - Parameter name of parameter #2 changed:
$inputto$string - Parameter type added for parameter #2 (
$string):string - Parameter type added for parameter #3 (
$offset):int - Parameter default value added for position #3 (
$offset):0
unpack(
- $format,
+ string $format,
- $input,
+ string $string,
- $offset
+ int $offset = 0
- )
+ ): array|false PHP 7.1
- Optional parameter added - #3:
$offset
-unpack($format, $input)
+unpack(
+ $format,
+ $input,
+ $offset
+ ) unpack Function Availability
unpack Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |