headermask image

header image

Proposal for a new Array Syntax in PHP

PHP LogoA new array syntax has been proposed (for quite some time) for defining arrays in PHP. Currently, we use array() construct to create an array. Some examples could be:

$myArray = array(1, 2, 3, 4, 5);
$yourArray = array(1 => “one”, 2 => “two”, “three”);
$herArray = array(1, 2, 3, array(4 => “four”, “five”));

The proposal is to use square brackets ( [ ] ) to define an array. If passed, we would be able rewrite the above examples as:


$myArray = [1, 2, 3, 4, 5];
$yourArray = [1 => "one", 2 => "two", "three");
$herArray = [1, 2, 3, [4 => "four", "five"]];

There’s a good deal of discussion going on in the internal mailing list with almost equal number of people voting “for” and “against” it. Rasmus, isn’t not very supportive, yet has voted for the new proposal.

To be pretty honest, I am still not very sure if it’s going to be worth the trade-offs.
Anyhoo! Let’s wait and watch. :)

If you liked my post, feel free to subscribe to my rss feeds

One Comment

  1. Hmm… Discuss…

    2. Niyaz PK on January 28th, 2008 at 2:43 pm

One Trackback

  1. By Pages tagged "the rasmus" on January 18, 2008 at 5:50 pm

    [...] = “0099FF”; var mooter_wrapper_url=”"; var run_method = “preload”; var mooter_target = “0″; Proposal for a new Array Syntax in PHP saved by 1 others     Genjustu bookmarked on 01/18/08 | [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*
Place your code as follows:
<pre name="code" class"language"> <pre/> language can be php, ruby etc.