Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60545 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59402 invoked from network); 13 May 2012 16:41:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2012 16:41:28 -0000 Authentication-Results: pb1.pair.com header.from=cpriest@zerocue.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cpriest@zerocue.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zerocue.com designates 74.115.204.51 as permitted sender) X-PHP-List-Original-Sender: cpriest@zerocue.com X-Host-Fingerprint: 74.115.204.51 migration-relay.domainlocalhost.com Windows 2000 SP2+, XP SP1 (seldom 98 4.10.2222) Received: from [74.115.204.51] ([74.115.204.51:34568] helo=relay-hub201.domainlocalhost.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/84-16338-534EFAF4 for ; Sun, 13 May 2012 12:41:27 -0400 Received: from MBX202.domain.local ([169.254.19.147]) by HUB201.domain.local ([192.168.69.1]) with mapi id 14.01.0355.002; Sun, 13 May 2012 12:41:22 -0400 To: "internals@lists.php.net" Thread-Topic: Array decomposition, more than list() Thread-Index: Ac0xJn+yf6T0Ob2LTKCPZ5AfUvHtog== Date: Sun, 13 May 2012 16:41:22 +0000 Message-ID: <9570D903A3BECE4092E924C2985CE48555C03DDF@MBX202.domain.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.64.26] Content-Type: multipart/alternative; boundary="_000_9570D903A3BECE4092E924C2985CE48555C03DDFMBX202domainloc_" MIME-Version: 1.0 Subject: Array decomposition, more than list() From: cpriest@zerocue.com (Clint Priest) --_000_9570D903A3BECE4092E924C2985CE48555C03DDFMBX202domainloc_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I've been using array decomposition in other languages such as Javascript r= ecently and find it very useful. I did not find any conversation about it = in the archives, has this topic been discussed/vetted/shot down already? Example use case: Indexed database results being iterated: Input: $tValues[$dbRow['ID1']][$dbRow['ID2']][$dbRow['ID3']] =3D $dbRow['Value']; Output: foreach($tValues as $ID1 =3D> $tSubValues1) { foreach($tSubValues1 as $ID2 =3D> $tSubValues2) { foreach($tSubValues2 as $ID3 =3D> $Value) { /* Do something, such as build an SQL insert */ } } } The above is a semi-common piece of code in our production application, I c= ould see list decomposition as a very convenient alternative. New functionality would support: foreach($tValues as $ID1 =3D> [$ID2 =3D> [$ID3 =3D> $Value] ]) { /* Do something */ } The above also would indicate that associative array key decomposition woul= d also be allowed. I don't believe anything like the above is possible, ev= en outside of a foreach loop, but perhaps I am wrong there. What do you think? -Clint --_000_9570D903A3BECE4092E924C2985CE48555C03DDFMBX202domainloc_--