Doc #61169 [Opn->Csd]: unpack() with unnamed elements

From: Date: Mon, 26 Sep 2016 17:01:17 +0000
Subject: Doc #61169 [Opn->Csd]: unpack() with unnamed elements
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13936@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61169&edit=1 ID: 61169 Updated by: cmb@php.net Reported by: anon at anon dot anon Summary: unpack() with unnamed elements -Status: Open +Status: Closed Type: Documentation Problem Package: Documentation problem PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2016-09-26 17:00:26] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&revision=340197 Log: Fix #61169: unpack() with unnamed elements ------------------------------------------------------------------------ [2012-02-23 13:24:58] anon at anon dot anon Description: ------------ --- From manual page: http://www.php.net/function.unpack#refsect1-function.unpack-notes --- A paragraph in the documentation for unpack says: >Be aware that if you do not name an element, an empty string is used. If you do not name more >than one element, this means that some data is overwritten as the keys are the same such as in: It is not correct that an empty string is used. The index 1 is used. var_dump(unpack('V', 'abcd')); array(1) { [1]=> int(1684234849) } (It could not be inferred that the documentation means an empty string with "1" appended, because the number is not appended to a lone entry's name:) var_dump(unpack('Vname', 'abcd')); array(1) { ["name"]=> int(1684234849) } Here's a clearer way to write it: >If you do not name an element, numeric indices starting from 1 are used. Be aware that if you >have more than one unnamed element, some data is overwritten because the numbering restarts from 1 >for each element. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61169&edit=1

« previous php.doc.bugs (#13936) next »