note 33995 added to function.unpack
| From: | cat at rack1 dot php dot net | Date: | Sun, 13 Jul 2003 02:04:31 +0000 |
| Subject: | note 33995 added to function.unpack | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52005@lists.php.net to get a copy of this message | ||
In response to DanRichter.at.programmer.dot.net:
I took at look at the PHP 5.3.3RC1 sources. This behavior of "standard arrays" only
appears to be so. In fact, this is because the creation of "key" strings for the resulting
array comes from a sprintf on "%.*s%d".
When the string passed for the type name is empty, you end up having a string with only a number in
it. (So, technically, it still is an associative array, only it has strings containing numbers for
keys, i.e. $array["1"], not $array[1])
Indeed, there is no way of getting around the start-at-1, or around the overwriting when using
multiple types, because of the way the associative array is filled:
sprintf(n, "%.*s%d", namelen, name, i + 1);
(where i is in a for() loop starting at 0)
----
Manual Page -- http://www.php.net/manual/en/function.unpack.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33995
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33995&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33995&report=yes