At present, arrays are a tad cumbersome to define. String keys must be quoted and followed by a double arrow, then the element ends with a comma:

$myArray = [ "stringKey" => 3 , "otherKey" => true , "foobar" => [ "anotherKey" => false , "andSoOn" => [ "moreKeys" => "thing" ] ] , "key with spaces" => "boo" ] ;

This adds up to a total of 5 characters that must be typed, 7 including spaces. However, in JavaScript, you do not need to quote key names if they fit the profile of a normal identifier (no spaces, doesn't begin with a digit, no dashes, etc.), making objects very convenient to define:

var myArray = { stringKey : 3 , otherKey : true , foobar : { anotherKey : false , andSoOn : { moreKeys : thing } } , "key with spaces" : "boo" } ;

This means only 3 characters must be typed (4 including spaces) for the most common case, which is far more convenient. Hence, this RFC proposes an optional similar syntax for PHP, where keys do not need to be quoted when they are followed by a colon instead of a double arrow, so long as they fit the profile of IS_STRING:

$myArray = [ stringKey : 3 , otherKey : true , foobar : [ anotherKey : false , andSoOn : [ moreKeys : thing ] ] , "key with spaces" => "boo" ] ;

This means that only 2 characters need to be typed (3 with spaces) for most key names. It makes defining arrays with string keys more convenient and it's easier to read (especially if you have an IDE which syntax highlights strings).

A secondary benefit is to the Named Parameters RFC in that it would provide a clear syntax choice consistent with arrays and the same as C# and Objective-C, i.e.:

$array = [ true , 3 , foo : 'bar' , "foo bar" => 7 ] ; call_user_func_array ( 'quxbang' , $array ) ; // is the same as: quxbang ( ... $array ) : // is the same as: quxbang ( true , 3 , foo : 'bar' , "foo bar" => 7 ) ;

Symmetry between arrays and named parameters would be desirable as otherwise it could cause confusion. This RFC would ensure it.

Even without named parameters, this makes it nicer to use functions which take an array of options. For example:

$ctx = stream_context_create ( [ http : [ method : "GET" , header : "Accept-language: en" , user_agent : 'Foo-Bot' , protocol_version : 1.1 ] ] ) ; // or $hash = password_hash ( $_POST [ 'pwd' ] , PASSWORD_BCRYPT , [ salt : $secure_salt , cost : 25 ] ) ;

This makes creating JSON more convenient, too:

// Real example $ws -> send ( json_encode ( [ type : 'join' , room : $player -> currentRoom , nick : $player -> curretName , x : 0 , y : 0 , avatar : 'foo.png' ] ) ) ;