Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45866 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69763 invoked from network); 22 Oct 2009 02:40:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Oct 2009 02:40:17 -0000 Authentication-Results: pb1.pair.com header.from=richardkmiller@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=richardkmiller@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.226 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: richardkmiller@gmail.com X-Host-Fingerprint: 209.85.220.226 mail-fx0-f226.google.com Received: from [209.85.220.226] ([209.85.220.226:59965] helo=mail-fx0-f226.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 68/B4-44649-016CFDA4 for ; Wed, 21 Oct 2009 22:40:17 -0400 Received: by fxm26 with SMTP id 26so11487257fxm.23 for ; Wed, 21 Oct 2009 19:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:mime-version :content-type:from:in-reply-to:date:cc:content-transfer-encoding :message-id:references:to:x-mailer; bh=PqfKUtpDL0bpOSfbMM/xO+ZLBx6bEyuEKIIJuSE6KN8=; b=Z6E0ZFhpxUhYM9GKbTgCPYEpKN4gXzUEmrsqr8GMNKB/b364YL5A/703PkpLo+ZnoM iWlm/Ux38wiAqeBzAVLEKY/ycKZc613CYa7Zb8190TB2F9WpC0+SlGHVA0NwLJFf+IrV eFRb3z9V64kW7K7UP+gemnl1m1IG8pxOWNABw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=hTUx67XGG4zeRjQsy1sOk80q1MtD9+JUseMMy3mVgAlXZBcup2xCJEiOzIMf4ltQPY p4kLm3DZWGttkie3lJS7GIHyJNwF58bUBluglpt9OP0CTdHEW/bIuUVeqL/7Fwwekp09 yf6hvPMCYDWy1T3iAXC0Frr1AaxaRZaptRmTI= Received: by 10.102.216.8 with SMTP id o8mr3826493mug.20.1256179214129; Wed, 21 Oct 2009 19:40:14 -0700 (PDT) Received: from ?192.168.1.110? ([76.8.194.242]) by mx.google.com with ESMTPS id s10sm1104862mue.52.2009.10.21.19.40.10 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 21 Oct 2009 19:40:12 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1076) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes In-Reply-To: Date: Wed, 21 Oct 2009 20:40:08 -0600 Cc: internals@lists.php.net Content-Transfer-Encoding: 7bit Message-ID: References: <84898698-728C-44ED-BF7A-E0E02C111F68@gmail.com> <4ADFB80B.9050207@hexon.cx> <304A7A3B-9E8D-4BA5-8C01-511090D5F236@gmail.com> To: mm w <0xcafefeed@gmail.com> X-Mailer: Apple Mail (2.1076) Subject: Re: [PHP-DEV] bug when using foreach with references? From: richardkmiller@gmail.com (Richard K Miller) I don't follow. Is this really the intended behavior? It seems quite unintuitive that the original array would be modified by *empty* loops. Suppose I create an include file that loops through $_GET variables with references: foreach ($_GET as &$get) { /* empty loop */ } Subsequent foreach() loops on $_GET would cause corruption. Seems dangerous. When would this behavior be desired? !intuitive && !desired == bug ? Richard On Oct 21, 2009, at 8:19 PM, mm w wrote: > Richard, enumerator exhausted, repeat your sub-sequence again you > will get it > e.g pointer and pointed > >> > $items = array('apple', 'banana', 'carrot'); >> print_r($items); >> foreach ($items as &$item) { } >> print_r($items); >> foreach ($items as $item) { } >> print_r($items);