Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67980 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9315 invoked from network); 27 Jun 2013 17:29:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2013 17:29:55 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.46 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.128.46 mail-qe0-f46.google.com Received: from [209.85.128.46] ([209.85.128.46:34377] helo=mail-qe0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0A/CF-34034-3967CC15 for ; Thu, 27 Jun 2013 13:29:55 -0400 Received: by mail-qe0-f46.google.com with SMTP id nd7so330538qeb.19 for ; Thu, 27 Jun 2013 10:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=yirVnoo9mtVAXDbbvgMqzYExI3LLv69AdAUxAXuDUhc=; b=bMln7cdSZpP9TAwg3AHPeQM0AY/U21wd9goJLFyGyRjEdqmAp7gQO52uw3w7DmVzX6 GJCdssnn51QbIkeSvAkOw056K2hhfUfDJEN3WsExdSChb8KJX48LOLFd4oy3dBUedLck r3eqTdnarA9YCyZ30h0Xy6KqiiyfBRAgGxtUqJrbfU1n3d9uaYVj9zVvrzYs8ke1+FEX GshThjcsuRcmVrDrcs9E/JQUpJSYEiJpngbQfEBOwPaMy1QID73dl7zyQtipMrL1YgkY up5l5mpjs/KMwRPvOhOE3Jx5MB8o8OwoK6/EoThzfQzIg/ryZaJ8glvuMRYo7jSpUmsx njZQ== MIME-Version: 1.0 X-Received: by 10.224.13.19 with SMTP id z19mr13201697qaz.12.1372354193023; Thu, 27 Jun 2013 10:29:53 -0700 (PDT) Sender: tjerk.meesters@gmail.com Received: by 10.49.99.67 with HTTP; Thu, 27 Jun 2013 10:29:52 -0700 (PDT) In-Reply-To: References: <4ED7146272E04A47B986ED49E771E347BB4DF6F344@Ikarus.ameusgmbh.intern> <1372349657.2376.4.camel@guybrush> Date: Fri, 28 Jun 2013 01:29:52 +0800 X-Google-Sender-Auth: yTDJEoauSsrO17HxGMNZC5BMqYk Message-ID: To: pierre@pcservice.co.za Cc: =?ISO-8859-1?Q?Johannes_Schl=FCter?= , Nikita Popov , Christian Stoller , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0149ce042e67dc04e0261c74 Subject: Re: [PHP-DEV] New syntax for multidimensional array loop with foreach From: datibbaw@php.net (Tjerk Anne Meesters) --089e0149ce042e67dc04e0261c74 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Fri, Jun 28, 2013 at 1:13 AM, Pierre du Plessis wrote: > 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 may= be > > 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; > } > And what about the "// and do something with $key and $innerKey" part? --=20 -- Tjerk --089e0149ce042e67dc04e0261c74--