This is about the last example of my previous post. For the sake of clarity, I'm including again here the example, which expands the one given in the formal documentation:
<?
$binarydata = "AA\0A";
$array = unpack("c2chars/nint", $binarydata);
foreach ($array as $key => $value)
echo "\$array[$key] = $value <br>\n";
?>
This outputs:
$array[chars1] = 65
$array[chars2] = 65
$array[int] = 65
Here, we assume that the ascii code for character 'A' is decimal 65.
Remebering that the format string structure is:
<format-code> [<count>] [<array-key>] [/ ...],
in this example, the format string instructs the function to
1. ("c2...") Read two chars from the second argument ("AA ...),
2. (...chars...) Use the array-keys "chars1", and "chars2" for
these two chars read,
3. (.../n...) Read a short int from the second argument (...\0A"),
4. (...int") Use the word "int" as the array key for the just read
short.
I hope this is clearer now,
Sergio.