for($i=0; $istrlen($packedData); $i++)
{
print("0x". dechex(ord($packedData[$i])).
" ");
}
print("\n");
//unpack the data
$Data = unpack("cOne/a10Two/nThree", $packedData);
//show all elements of the unpacked array
while(list($key, $value) = each($Data))
{
print("$key = $value
\n");
}
?>
Table 9.6. Pack Codes
Code Data Type Description
a String
Repeat count is the number of characters to take from the string. If
there are fewer characters in the string than specified by the repeat
count, spaces are used to pad it out.
A String
Repeat count is the number of characters to take from the string. If
there are fewer characters in the string than specified by the repeat
count, nulls (ASCII 0) are used to pad it out.
c Integer The integer will be converted to a signed character.
C Integer The integer will be converted to an unsigned character.
d Double
The double will be stored in double-width floating-point format.
Depending on your operating system, this is probably 8 bytes.
f Double The double will be converted to a single-width floating-point format. Depending on your operating system, this is probably 4 bytes.
h String
The ASCII value of each character of the argument will be saved as two
characters representing the ASCII code in hexadecimal, big-endian. The
repeat count denotes the number of characters to take from the input.
H String
The ASCII value of each character of the argument will be saved as two
characters representing the ASCII code in hexadecimal, little-endian.
The repeat count denotes the number of characters to take from the
input.
i Integer The argument will be saved as an unsigned integer. Typically this is 4 bytes.
I Integer
The argument will be saved as a signed integer. Typically this is 4
bytes, with one bit used for sign.
l Integer The argument is saved as an unsigned long, which is usually 8 bytes.
L Integer The argument is saved as a signed long, which is usually 8 bytes with one bit used for sign.