Bug #73033 [Opn->Wfx]: When in a foreach, the next function return the n+2 element

From: Date: Tue, 06 Sep 2016 17:32:54 +0000
Subject: Bug #73033 [Opn->Wfx]: When in a foreach, the next function return the n+2 element
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203841@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73033&edit=1 ID: 73033 Updated by: nikic@php.net Reported by: louiscelier at gmail dot com Summary: When in a foreach, the next function return the n+2 element -Status: Open +Status: Wont fix Type: Bug Package: Arrays related Operating System: linux PHP Version: 5.6.25 Block user comment: N Private report: N New Comment: This behavior changed as part of https://wiki.php.net/rfc/php7_foreach, which was a significant change to foreach semantics. It will not be applied to PHP 5.6. Previous Comments: ------------------------------------------------------------------------ [2016-09-06 17:28:12] louiscelier at gmail dot com Description: ------------ --- From manual page: http://www.php.net/function.next --- When in a foreach on an array, the next function used on the same array does not return the n+1 element but the n+2 element. This bug appeared with the 5.2.4 version of PHP and it is still present on 5.6.* It is absend of version7 and of hhvm https://3v4l.org/hg1Of Test script: --------------- $array = array(array(0,0), array(0,5), array(5,5), array(5,0), array(0,0)); foreach ($array as $point) { $next = next($array); var_dump($point, $next); } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73033&edit=1

« previous php.bugs (#203841) next »