Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34783 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28525 invoked by uid 1010); 14 Jan 2008 15:26:44 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 28510 invoked from network); 14 Jan 2008 15:26:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2008 15:26:44 -0000 X-Host-Fingerprint: 213.16.46.130 pirus.securax.be Received: from [213.16.46.130] ([213.16.46.130:29619] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/74-25379-13F7B874 for ; Mon, 14 Jan 2008 10:26:41 -0500 Message-ID: <05.74.25379.13F7B874@pb1.pair.com> To: internals@lists.php.net Date: Mon, 14 Jan 2008 17:27:11 +0200 Reply-To: kouber@php.net User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 References: <1200066425.7376.9.camel@johannes.nop> In-Reply-To: <1200066425.7376.9.camel@johannes.nop> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 213.16.46.130 Subject: Re: SUMMARY: Array syntax From: kouber@php.net (Kouber Saparev) A +1 from me (in case my vote counts). The main reason behind it is readability: $x = array(1 => array(1, 2, 3), array(array(1), 2)); vs. $x = [1 => [1, 2, 3], [[1], 2]]; The latter form looks much better to me - it is faster to read and to understand it (and to type it, of course, although it shouldn't be a factor), especially for such multi-dimensional definitions. The benefit of using the new syntax is even bigger when dealing with function calls + conditionals: if (in_array($z, array(1, 2, 3))) { $s = str_replace(array('a', 'b', 'c'), array('d', 'e', 'f'), 'abc'); } vs. if (in_array($z, [1, 2, 3])) { $s = str_replace(['a', 'b', 'c'], ['d', 'e', 'f'], 'abc'); } With the "square brackets" syntax a pair of redundant parantheses is removed, thus making it easier to distinguish between data definition and function call (conditional, expression...) closures and helping identify arrays among such compound structures. ;-) Regards, -- Kouber Saparev http://kouber.saparev.com