php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #62595 array_slice documentation error
Submitted: 2012-07-18 11:24 UTC Modified: 2012-07-18 11:33 UTC
From: theanomaly dot is at gmail dot com Assigned: nikic (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: theanomaly dot is at gmail dot com
New email:
PHP Version: OS:

 

 [2012-07-18 11:24 UTC] theanomaly dot is at gmail dot com
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)

Patches

array_slice-note-fix (last revision 2012-07-18 11:25 UTC by theanomaly dot is at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-18 11:33 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2012-07-18 11:33 UTC] nikic@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.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 00:00:02 2026 UTC