|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37623 offsetUnset() on foreached arrayObject item throw E_NOTICE
Submitted: 2006-05-29 09:27 UTC Modified: 2006-05-29 18:29 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: sperson at lfdj dot com Assigned: helly (profile)
Status: Not a bug Package: SPL related
PHP Version: 5.* OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: sperson at lfdj dot com
New email:
PHP Version: OS:


 [2006-05-29 09:27 UTC] sperson at lfdj dot com
When we do a foreach on an arrayObject, and we want to unset some item from the loop a NOTICE is thrown.

Don't know if this is the intended behaviour but in case of doubt I prefer to submit.

Reproduce code:
$coll = new ArrayObject();
$coll->append(new stdClass());
foreach ($coll as $index => $item) {

Expected result:

Actual result:
Notice: main() [function.main]: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid in index.php on line 7


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-29 09:48 UTC]
AFAICT this is intended.
 [2006-05-29 18:29 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

The notice means that foreach rewinds or moves to its end. Whatever the ArrayIterator decides.
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sat Oct 20 06:01:26 2018 UTC