php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27782 Wrong behaviour of next() and prev()
Submitted: 2004-03-30 12:09 UTC Modified: 2004-03-30 15:11 UTC
From: giovanni at giacobbi dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.4 OS: Linux
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: giovanni at giacobbi dot net
New email:
PHP Version: OS:

 

 [2004-03-30 12:09 UTC] giovanni at giacobbi dot net
Description:
------------
As stated in documentation, next() returns the NEXT element in the array and THEN increases internal pointer. Thus, when this function returns FALSE, I expect the internal pointer to be in the last position, thus prev() should return end()-1 element.


Reproduce code:
---------------
<?php
$a = array("a", "b", "c");
reset($a);
while (next($a) !== FALSE);
var_dump(prev($a));


Expected result:
----------------
string(1) "b"


Actual result:
--------------
bool(false)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-30 14:00 UTC] iliaa@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 [2004-03-30 15:11 UTC] giovanni at giacobbi dot net
the following revision:
+++ ext/standard/array.c        30 Mar 2004 19:09:10 -0000      1.199.2.31

has been tested and perfectly works.
Thank you.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 09:01:27 2025 UTC