Bug #60427 [Csd]: array_reverse docs are slightly misleading
| From: | me at andyclyde dot com | Date: | Fri, 02 Dec 2011 13:10:43 +0000 |
| Subject: | Bug #60427 [Csd]: array_reverse docs are slightly misleading | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-7494@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60427&edit=1
ID: 60427
User updated by: me at andyclyde dot com
Reported by: me at andyclyde dot com
Summary: array_reverse docs are slightly misleading
Status: Closed
Type: Bug
Package: Documentation problem
Operating System: n/a
PHP Version: Irrelevant
Assigned To: gooh
Block user comment: N
Private report: N
New Comment:
Great, thanks. Just one thing though, you have a typo in the text you added to the comment (not sure
if you c'n'p'ed it or whether it's just an error in your comment:
"regardless of preserve_keys being true of false"
should be
"regardless of preserve_keys being true or false"
Previous Comments:
------------------------------------------------------------------------
[2011-12-02 13:05:33] gooh@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
I have added clarification that setting preserve_keys will only affect numeric keys. Non-numeric
keys are always preserved, regardless of preserve_keys being true of false.
------------------------------------------------------------------------
[2011-12-02 13:00:25] gooh@php.net
Automatic comment from SVN on behalf of gooh
Revision: http://svn.php.net/viewvc/?view=revision&revision=320282
Log: fixes Bug #60427: array_reverse docs are slightly misleading
------------------------------------------------------------------------
[2011-12-01 14:51:27] me at andyclyde dot com
Description:
------------
The doc page for array_reverse() states that there is a second parameter "preserve_keys".
In fact this doesn't seem to have any effect if the array is purely associative whatever you
set the second parameter to. This behaviour seems fine but it's not obvious from the docs.
I think this is possibly the same issue as bug #41396.
Test script:
---------------
$array = array( 'one' => 1, 'two' => 2 );
$array = array_reverse( $array, false );
var_dump( $array );
Expected result:
----------------
From the docs you might expect this to return:
array(2) {
["one"]=>
int(2)
["two"]=>
int(1)
}
Actual result:
--------------
array(2) {
["two"]=>
int(2)
["one"]=>
int(1)
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60427&edit=1