note 106060 added to arrayiterator.next

From: Date: Thu, 06 Oct 2011 18:09:03 +0000
Subject: note 106060 added to arrayiterator.next
Groups: php.notes 
Request: Send a blank email to php-notes+get-183673@lists.php.net to get a copy of this message
If you use exchangeArray method of ArrayObject and then next method of ArrayIterator like this: <?php $fruits = array("apple", "grape", "lemon"); $colors = array("blue", "yellow", "green"); $arrayObject = new ArrayObject($fruits); $arrayIterator = $arrayObject->getIterator(); while($arrayIterator->valid()) { if ($arrayIterator->current() == "grape") { $arrayObject->exchangeArray($colors); } $arrayIterator->next(); } ?> You will receive: PHP Notice: ArrayIterator::next(): Array was modified outside object and internal position is no longer valid So be careful with next and prev operations. :) ---- Server IP: 187.73.33.5 Probable Submitter: 189.1.165.34 ---- Manual Page -- http://www.php.net/manual/en/arrayiterator.next.php Edit -- https://master.php.net/note/edit/106060 Del: integrated -- https://master.php.net/note/delete/106060/integrated Del: useless -- https://master.php.net/note/delete/106060/useless Del: bad code -- https://master.php.net/note/delete/106060/bad+code Del: spam -- https://master.php.net/note/delete/106060/spam Del: non-english -- https://master.php.net/note/delete/106060/non-english Del: in docs -- https://master.php.net/note/delete/106060/in+docs Del: other reasons-- https://master.php.net/note/delete/106060 Reject -- https://master.php.net/note/reject/106060 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183673) next »