Bug #70812 [NEW]: Nested foreach with iterators
From: fra dot casula at gmail dot com
Operating system: Ubuntu 15.10 x64
PHP version: 5.6.14
Package: *General Issues
Bug Type: Bug
Bug description:Nested foreach with iterators
Description:
------------
A nested foreach on the same iterator doesn't produce the same result
that is produced when using plain arrays.
The nested foreach should call seek() to reset the internal pointer to
its correct position so that the first foreach can resume where it
stopped.
Test script:
---------------
http://pastebin.com/EQrUZ7AQ
Expected result:
----------------
I expect to see the same output for all four cases in the example code.
The expected output is:
first loop 0
second loop 0
second loop 1
second loop 2
first loop 1
second loop 0
second loop 1
second loop 2
first loop 2
second loop 0
second loop 1
second loop 2
Actual result:
--------------
first loop 0
second loop 0
second loop 1
second loop 2
--
Edit bug report at https://bugs.php.net/bug.php?id=70812&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70812&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70812&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70812&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70812&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70812&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70812&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70812&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70812&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70812&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70812&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70812&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70812&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70812&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70812&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70812&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70812&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70812&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70812&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70812&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70812&r=mysqlcfg
Thread (5 messages)
- fra dot casula at gmail dot com