Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67978 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6030 invoked from network); 27 Jun 2013 17:14:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2013 17:14:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre@pcservice.co.za; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre@pcservice.co.za; sender-id=pass Received-SPF: pass (pb1.pair.com: domain pcservice.co.za designates 67.18.34.23 as permitted sender) X-PHP-List-Original-Sender: pierre@pcservice.co.za X-Host-Fingerprint: 67.18.34.23 gateway03.websitewelcome.com Linux 2.6 Received: from [67.18.34.23] ([67.18.34.23:36691] helo=gateway03.websitewelcome.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/1F-34034-8E27CC15 for ; Thu, 27 Jun 2013 13:14:17 -0400 Received: by gateway03.websitewelcome.com (Postfix, from userid 5007) id 41EAF3E779685; Thu, 27 Jun 2013 12:14:14 -0500 (CDT) Received: from vinacomin.websitewelcome.com (vinacomin.websitewelcome.com [50.97.101.199]) by gateway03.websitewelcome.com (Postfix) with ESMTP id 0C1EC3E779590 for ; Thu, 27 Jun 2013 12:14:14 -0500 (CDT) Received: from [209.85.216.52] (port=64638 helo=mail-qa0-f52.google.com) by vinacomin.websitewelcome.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.80) (envelope-from ) id 1UsFlt-0007cv-Sm for internals@lists.php.net; Thu, 27 Jun 2013 12:14:13 -0500 Received: by mail-qa0-f52.google.com with SMTP id bv4so749338qab.11 for ; Thu, 27 Jun 2013 10:14:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=7m7awKx2IK6GG8qybxyvN9X7zNWT823v8AXeErhgmNQ=; b=FygD+fU7AnMnhS9vQSuZTj/5yTOhDwDC0GcohCIMqzGM3PUEX9PltD+b1QsAnF9K5o T7XUrM03cPIa1oAKE6KaAEWFRDtdkSioWyu/iEBhV0eVDA/Q5c1Xj0gwK4LEFrF8T0fV JVFdzkJFg9fNy0YL+96DaAXSYV6IVZCTmAnp3hZv/r9NRTBIDrqU+B2Dk7kci9KhCDyW d0zgeAstDQgkaSVRU3Y3+v418wnOpbu2VkhLmg9R0sg+cxzjCu+5s/gphxtCwg546zae XLbvKZP7IOo2zaHB/g13AtW4l6NvuUZoRCBw68g5nOCNDl6g4h+T4rVEm0qvFccA8N9j utzw== X-Received: by 10.229.106.18 with SMTP id v18mr2870845qco.49.1372353253210; Thu, 27 Jun 2013 10:14:13 -0700 (PDT) MIME-Version: 1.0 Reply-To: pierre@pcservice.co.za Received: by 10.49.76.179 with HTTP; Thu, 27 Jun 2013 10:13:43 -0700 (PDT) In-Reply-To: <1372349657.2376.4.camel@guybrush> References: <4ED7146272E04A47B986ED49E771E347BB4DF6F344@Ikarus.ameusgmbh.intern> <1372349657.2376.4.camel@guybrush> Date: Thu, 27 Jun 2013 19:13:43 +0200 Message-ID: To: =?ISO-8859-1?Q?Johannes_Schl=FCter?= Cc: Nikita Popov , Christian Stoller , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=002354470a342a08f704e025e42a X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vinacomin.websitewelcome.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - pcservice.co.za X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (mail-qa0-f52.google.com) [209.85.216.52]:64638 X-Source-Auth: pierre@pcservice.co.za X-Email-Count: 3 X-Source-Cap: cGNzZXJ2aWM7cGllcnJlO3ZpbmFjb21pbi53ZWJzaXRld2VsY29tZS5jb20= Subject: Re: [PHP-DEV] New syntax for multidimensional array loop with foreach From: pierre@pcservice.co.za (Pierre du Plessis) --002354470a342a08f704e025e42a Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Thu, Jun 27, 2013 at 6:14 PM, Johannes Schl=FCter wrote: > On Thu, 2013-06-27 at 16:58 +0200, Nikita Popov wrote: > > On Thu, Jun 27, 2013 at 4:10 PM, Christian Stoller >wrote: > > > > > The new syntax could make it shorter and faster to write... but maybe > it's > > > a bit too confusing? > > > > > > $count =3D 0; > > > foreach ($array as $key =3D> $innerArray as $innerKey =3D> $value) { > > > $count +=3D $value; > > > // and do something with $key and $innerKey > > > } > > > > With the addition of array_column in php 5.5, this can be done in a much cleaner way: $array =3D array( array('value' =3D> 1), array('value' =3D> 2), array('value' =3D> 3), ); $count =3D 0; foreach(array_column($array, 'value') as $value) { $count +=3D $value; } --002354470a342a08f704e025e42a--