Doc #62595 [NEW]: array_slice documentation error
| From: | theanomaly dot is at gmail dot com | Date: | Wed, 18 Jul 2012 11:24:20 +0000 |
| Subject: | Doc #62595 [NEW]: array_slice documentation error | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-8566@lists.php.net to get a copy of this message | ||
From: theanomaly dot is at gmail dot com
Operating system:
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:array_slice documentation error
Description:
------------
The documentation for array_slice currently states that "Note: This
function will
reset() the array pointer of the input array after use.", which is not
true. After
having reviewed the source and confirmed with a test I'm submitting a patch
to
remove this note from the docs.
Below I've provided a test script to prove that this behavior is
non-existent.
I also have a patch from edit.php.net to remove this note. Thanks.
Test script:
---------------
<?php
$array = array(1,2,3,4);
/* This should produce int(2) */
var_dump(next($array));
$slice = array_slice($array, -1);
/* This should still produce int(2) */
var_dump(current($array));
$slice = array_slice($array, 2, 1);
/* This should still produce int(2) */
var_dump(current($array));
/* This proves the array's internal pointer was never changed by
array_slice() */
Expected result:
----------------
int(2) int(1) int(1)
Actual result:
--------------
int(2) int(2) int(2)
--
Edit bug report at https://bugs.php.net/bug.php?id=62595&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62595&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62595&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62595&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62595&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62595&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62595&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62595&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62595&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62595&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62595&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62595&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62595&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62595&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62595&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62595&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62595&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62595&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62595&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62595&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62595&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62595&r=mysqlcfg