Doc #62804 [Opn->Csd]: array_slice(): Undocumented huge difference in behavior of across 5.2.4
| From: | krakjoe@php.net | Date: | Wed, 23 Oct 2013 08:10:31 +0000 |
| Subject: | Doc #62804 [Opn->Csd]: array_slice(): Undocumented huge difference in behavior of across 5.2.4 | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10529@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62804&edit=1
ID: 62804
Updated by: krakjoe@php.net
Reported by: matteosistisette at gmail dot com
Summary: array_slice(): Undocumented huge difference in
behavior of across 5.2.4
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
-Assigned To:
+Assigned To: krakjoe
Block user comment: N
Private report: N
New Comment:
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.
A note has been added to the changelog.
Thanks for your input.
Previous Comments:
------------------------------------------------------------------------
[2013-10-23 08:10:09] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&revision=331920
Log: #62804 add information about parameter change in changelog
------------------------------------------------------------------------
[2012-12-12 17:44:28] alvaro at demogracia dot com
Possible workaround:
<?php
$foo = array_slice($bar, 1, count($bar)-1, TRUE);
?>
------------------------------------------------------------------------
[2012-08-12 20:06:33] matteosistisette at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.array-slice#refsect1-
function.array-slice-description
---
array array_slice ( array $array , int $offset [, int $length = NULL [, bool
$preserve_keys = false ]] )
That the default value of the $length parameter is NULL is true only for php
>=5.2.4
Prior to that version, passing NULL is NOT the same as omitting it.
Check this: http://3v4l.org/gW4pG
Note the difference in output between 5.2.3 and 5.2.4
Only starting from 5.2.4 it is as documented.
This has a TREMENDOUS impact and must be documented with a gigantic red warning.
Instead, it is not even mentioned.
The sentence "If it is omitted, then the sequence will have everything from
offset up until the end of the array." _is_ correct for all version, but if one
needs to specify the $preserve_keys parameter without specifying $length, one
needs to pass the default value (that's why it's very relevant), and the value
has changed.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62804&edit=1