[UPHPU] buggy behavior with two foreach loops

William Attwood wattwood at gmail.com
Tue Oct 20 01:44:24 MDT 2009


Disregard that last one .

Can you alter to print in the loops so we can see where th bug/error  
occurs?

Sent from my iPhone

On Oct 20, 2009, at 1:10 AM, Richard K Miller  
<richardkmiller at gmail.com> wrote:

> Is this a bug in PHP?
>
> <?php
>
> $items = array('apple', 'banana', 'carrot');
>
> print_r($items);
>
> foreach ($items as &$item) { }
>
> print_r($items);
>
> foreach ($items as $item) { }
>
> print_r($items);
>
> // Output:
>
> Array
> (
>     [0] => apple
>     [1] => banana
>     [2] => carrot
> )
> Array
> (
>     [0] => apple
>     [1] => banana
>     [2] => carrot
> )
> Array
> (
>     [0] => apple
>     [1] => banana
>     [2] => banana
> )
>
> Two bananas in the last set?! Not what I expected.
>
> Richard
>
>
>
> _______________________________________________
>
> UPHPU mailing list
> UPHPU at uphpu.org
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net


More information about the UPHPU mailing list