note 33995 deleted from function.unpack by didou
| From: | didou@php.net | Date: | Tue, 19 Aug 2003 14:12:04 +0000 |
| Subject: | note 33995 deleted from function.unpack by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54679@lists.php.net to get a copy of this message | ||
Note Submitter: cat(at)vv(dot)carleton(dot)ca
----
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)