Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19049 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86708 invoked by uid 1010); 16 Sep 2005 12:40:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 86693 invoked from network); 16 Sep 2005 12:40:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2005 12:40:14 -0000 X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:39094] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id EF/DC-43379-C2DBA234 for ; Fri, 16 Sep 2005 08:40:13 -0400 Received: (qmail 11172 invoked from network); 16 Sep 2005 12:40:07 -0000 Received: from internal.zend.office (HELO ?127.0.0.1?) (10.1.1.1) by internal.zend.office with SMTP; 16 Sep 2005 12:40:07 -0000 Message-ID: <432ABD29.6000605@zend.com> Date: Fri, 16 Sep 2005 16:40:09 +0400 User-Agent: Thunderbird 1.4 (X11/20050907) MIME-Version: 1.0 To: Ron Korving CC: internals@lists.php.net References: <67.0C.43379.BCABA234@pb1.pair.com> In-Reply-To: <67.0C.43379.BCABA234@pb1.pair.com> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] big reference bug in (at least) PHP 5.0.5 From: antony@zend.com (Antony Dovgal) On 16.09.2005 16:29, Ron Korving wrote: > My apologies for my DOM-mistake today, but right now I came across something > that totally stunned me. It's a total paradox situation that just has to be > one of the biggest bugs I've ever come across in PHP. Personally, I think > it's rather high-priority because it's an engine problem, and not an issue > with some extension. > > Here's the code: > > $array = array(); > > for ($i=0; $i < 3; $i++) > $array[] = array("foo" => $i); > > foreach ($array as &$item) > $item["bar"] = $item["foo"] * 2; > > print_r($array); > > foreach ($array as $item) > print_r($item); > ?> Ron, after the first foreach $item still points to the last element of $array (because you've used &$item syntax). The second foreach changes $item, but it *STILL* references the last element of $array, so it actually changes it instead. Try to change this part of the code: foreach ($array as $item) print_r($item); to: foreach ($array as $blah) print_r($blah); you'll see it yourself. I don't see any bugs here. -- Wbr, Antony Dovgal