Bug #60427 [Com]: array_reverse docs are slightly misleading

From: Date: Fri, 02 Dec 2011 13:33:38 +0000
Subject: Bug #60427 [Com]: array_reverse docs are slightly misleading
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7495@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 Comment by: gooh@php.net 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: Thanks. It's just in the comments though. The docs will read If set to &true; numeric keys are preserved. Non-numeric keys are not affected by this setting and will always be preserved. Previous Comments: ------------------------------------------------------------------------ [2011-12-02 13:10:43] me at andyclyde dot com 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" ------------------------------------------------------------------------ [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

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