Re: big reference bug in (at least) PHP 5.0.5
| From: | Matthew Charles Kavanagh | Date: | Fri, 16 Sep 2005 13:05:17 +0000 |
| Subject: | Re: big reference bug in (at least) PHP 5.0.5 | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-19052@lists.php.net to get a copy of this message | ||
Ron Korving wrote:
>The last item in the array is replaced, not by the first one of the second
>foreach, but by the item before the last item. That just doesn't make sense
>at all.
>
>
This is where you're going wrong (and where I was going wrong in
thinking about this before Antony's message). $item points to $array[2]
the whole time, and $array[2] is first overwritten by $array[0], then
$array[1], then $array[2].
This is a pretty interesting oddity in references that I hadn't
considered, though, and I'll be thinking about bizarre things I can do
with this for a while. :)