php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #61157 Documentation says array_slice() resets array pointer, but it doesn't.
Submitted: 2012-02-21 19:47 UTC Modified: 2012-07-18 11:39 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ben at bravenet dot com Assigned: nikic (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: n/a
Private report: No CVE-ID: None
 [2012-02-21 19:47 UTC] ben at bravenet dot com
Description:
------------
In the documentation at http://php.net/array_slice it states:

"Note: This function will reset() the array pointer of the input array after use."

However, a quick test shows that this is not the case.




Test script:
---------------
$array = array(1, 2, 3);
next($array);  //move pointer to second position (key 1)
var_dump(current($array));  //output int(2)
$last = array_slice($array, -1);  //get last element
var_dump(current($array));  //output int(2) pointer not reset!


Patches

Pull Requests

History

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