On Oct 20, 2009, at 12:10 AM, Richard K Miller wrote: > Is this a bug in PHP? >
These reports describe the issue (though more verbosely): http://bugs.php.net/bug.php?id=29992 http://bugs.php.net/bug.php?id=31118 http://bugs.php.net/bug.php?id=31125 http://bugs.php.net/bug.php?id=36240 Seems odd for Derick and Andi to disregard this as "expected behavior". The fix is to unset() the iterator value before the second foreach loop. (Why should that be necessary?) <?php $items = array('apple', 'banana', 'carrot'); print_r($items); foreach ($items as &$item) { } print_r($items); unset ($item); // required foreach ($items as $item) { } print_r($items); _______________________________________________ UPHPU mailing list [email protected] http://uphpu.org/mailman/listinfo/uphpu IRC: #uphpu on irc.freenode.net
