Bug #62487 [NEW]: next/current and each behave differently with unset
| From: | justin at crowdfavorite dot com | Date: | Thu, 05 Jul 2012 22:07:27 +0000 |
| Subject: | Bug #62487 [NEW]: next/current and each behave differently with unset | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-171757@lists.php.net to get a copy of this message | ||
From: justin at crowdfavorite dot com
Operating system: OS X
PHP version: 5.4.4
Package: Arrays related
Bug Type: Bug
Bug description:next/current and each behave differently with unset
Description:
------------
Removing the current array element using unset() while iterating through
the array with next() and current() causes the array pointer to miss the
next array element.
Removing the /next/ array element with unset() while iterating through the
array with each() does /not/ cause similar behavior - the array element
following is correctly picked up at the next call to each().
It seems like the behavior with next()/current() is incorrect (but that it
would be good for the behavior to be consistent regardless).
Test script:
---------------
example code: http://pastebin.com/5HMumA0A
Expected result:
----------------
12345 - expected
12345
1245 - expected
1245
12345 - expected
12345
Actual result:
--------------
12345 - expected
12345
1245 - expected
1245
12345 - expected
1245
--
Edit bug report at https://bugs.php.net/bug.php?id=62487&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62487&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62487&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62487&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62487&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62487&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62487&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62487&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62487&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62487&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62487&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62487&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62487&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62487&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62487&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62487&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62487&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62487&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62487&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62487&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62487&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62487&r=mysqlcfg