Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19052 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1605 invoked by uid 1010); 16 Sep 2005 13:03:25 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 1590 invoked from network); 16 Sep 2005 13:03:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2005 13:03:25 -0000 X-Host-Fingerprint: 83.149.123.177 mail.aaaa.ws Linux 2.4/2.6 Received: from ([83.149.123.177:35183] helo=mail.aaaa.ws) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 21/2F-43379-C92CA234 for ; Fri, 16 Sep 2005 09:03:24 -0400 Received: from cpc2-sout5-5-0-cust53.sot3.cable.ntl.com ([81.110.110.53] helo=[192.168.1.103]) by mail.aaaa.ws with esmtpa (Exim 4.50) id 1EGFs8-0000tu-Ei; Fri, 16 Sep 2005 15:03:20 +0200 Message-ID: <432AC30D.1050105@teh.ath.cx> Date: Fri, 16 Sep 2005 14:05:17 +0100 User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050912) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ron Korving CC: internals@lists.php.net References: <67.0C.43379.BCABA234@pb1.pair.com> <432ABD29.6000605@zend.com> <96.CE.43379.260CA234@pb1.pair.com> In-Reply-To: <96.CE.43379.260CA234@pb1.pair.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] big reference bug in (at least) PHP 5.0.5 From: matthew@teh.ath.cx (Matthew Charles Kavanagh) 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. :)