#40028 [Opn->Bgs]: Wrong behaviour of next() and prev()

From: Date: Fri, 05 Jan 2007 22:10:12 +0000
Subject: #40028 [Opn->Bgs]: Wrong behaviour of next() and prev()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-107217@lists.php.net to get a copy of this message
ID: 40028 Updated by: iliaa@php.net Reported By: prometheus__0 at hotmail dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Linux Sles10 PHP Version: 5.2.1RC2 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2007-01-05 09:59:59] 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) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40028&edit=1

« previous php.bugs (#107217) next »