php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45787 Shorthand array notation
Submitted: 2008-08-11 14:50 UTC Modified: 2008-08-11 14:53 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: icyliquid at gmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.6 OS: All
Private report: No CVE-ID: None
 [2008-08-11 14:50 UTC] icyliquid at gmail dot com
Description:
------------
After a year of heavy Javascript coding, my return to PHP has been marked with mixed feelings. One thing bothering me is (what seems to me to be) the cumbersome array syntax of PHP.

Javascript has:

var arr = [ 'foo', 'bar', 'baz' ... ];

Obviously, PHP supports associative arrays and Javascript coders have to resort their language's Object class for achieve that, so perhaps the JS object syntax works better here:

var obj = { 'key':'value', 'otherkey':'otherval' ... };

I have found myself passing arrays to methods on an increasingly frequent basis, and I think that a concise syntax like this would go a long way to increasing readability.

What do you guys think?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-11 14:53 UTC] lstrojny@php.net
This has been discussed in the past and was declined. See http://wiki.php.net/rfc/shortsyntaxforarrays for details.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 23:01:32 2025 UTC