Bug #73033 [NEW]: When in a foreach, the next function return the n+2 element
| From: | louiscelier at gmail dot com | Date: | Tue, 06 Sep 2016 17:28:13 +0000 |
| Subject: | Bug #73033 [NEW]: When in a foreach, the next function return the n+2 element | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-203840@lists.php.net to get a copy of this message | ||
From: louiscelier at gmail dot com
Operating system: linux
PHP version: 5.6.25
Package: Arrays related
Bug Type: Bug
Bug description:When in a foreach, the next function return the n+2 element
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 bug report at https://bugs.php.net/bug.php?id=73033&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73033&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73033&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73033&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73033&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73033&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73033&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73033&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73033&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73033&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73033&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73033&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73033&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73033&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73033&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73033&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73033&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73033&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73033&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73033&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73033&r=mysqlcfg