Doc #60320 [Opn->Csd]: inaccuracy in array_slice documentation for length parameter
| From: | rquadling@php.net | Date: | Thu, 17 Nov 2011 16:29:15 +0000 |
| Subject: | Doc #60320 [Opn->Csd]: inaccuracy in array_slice documentation for length parameter | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-7441@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60320&edit=1
ID: 60320
Updated by: rquadling@php.net
Reported by: alastair at propcom dot co dot uk
Summary: inaccuracy in array_slice documentation for length
parameter
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: all
PHP Version: Irrelevant
-Assigned To:
+Assigned To: rquadling
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2011-11-17 16:29:03] rquadling@php.net
Automatic comment from SVN on behalf of rquadling
Revision: http://svn.php.net/viewvc/?view=revision&revision=319411
Log: A short array alters length description.
Fixes bug #60320
------------------------------------------------------------------------
[2011-11-17 16:07:32] alastair at propcom dot co dot uk
Description:
------------
The description of the 'length' parameter says "If length is given and is
positive, then the sequence will have that many elements in it.". This is only
true if there are that many elements. If the array is shorter than that, the
sequence will not be forcibly extended; instead it will have as many elements as
could be extracted from the array.
Test script:
---------------
var_dump( array_slice( array(1, 2, 3), 0, 5 ) );
Expected result:
----------------
array (
0 => 1,
1 => 2,
2 => 3,
3 => null,
4 => null,
)
Actual result:
--------------
array (
0 => 1,
1 => 2,
2 => 3,
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60320&edit=1