php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40028 Wrong behaviour of next() and prev()
Submitted: 2007-01-05 09:59 UTC Modified: 2007-01-05 22:10 UTC
From: prometheus__0 at hotmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.1RC2 OS: Linux Sles10
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: prometheus__0 at hotmail dot com
New email:
PHP Version: OS:

 

 [2007-01-05 09:59 UTC] prometheus__0 at hotmail dot com
Description:
------------
the bug report with id 27782 is the same as this one
http://bugs.php.net/bug.php?id=27782

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.

i tested it with older php5 versions and it seems this bug occures within all php5 versions

bug http://bugs.php.net/bug.php?id=37598 occures too

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
 [2007-01-05 22:10 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Original patch was reverted due to the BC issues it introduces 
in relation to the key() function. The current behavior is 
designated as expected.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Apr 23 03:01:30 2025 UTC