Array Declarations

This standard covers all array declarations, regardless of the number and type of values contained within the array.
The <em>array</em> keyword must be lowercase.

Valid: Array keyword lowercase.

$array = array('val1', 'val2');

Invalid: First letter capitalised.

$array = Array('val1', 'val2');
The first array key must begin on the line after the <em>array</em> keyword.

Valid: First key on second line.

$array = array( 'key1' => 'value1', 'key2' => 'value2', );

Invalid: First key on same line.

$array = array('key1' => 'value1', 'key2' => 'value2', );
All array keys must be indented to one space after the start of the <em>array</em> keyword. The closing parenthesis must be aligned with the start of the <em>array</em> keyword.

Valid: Aligned correctly.

$array = array( <em> </em>'key1' => 'value1', <em> </em>'key2' => 'value2', );

Invalid: Keys and parenthesis aligned incorrectly.

$array = array( <em>'</em>key1' => 'value1', <em>'</em>key2' => 'value2', );
All double arrow symbols must be aligned to one space after the longest array key. Alignment must be achieved using spaces.

Valid: Keys and values aligned.

$array = array( 'keyTen'<em> </em>=> 'ValueTen', 'keyTwenty'<em> </em>=> 'ValueTwenty', );

Invalid: Alignment incorrect.

$array = array( 'keyTen'<em> </em>=> 'ValueTen', 'keyTwenty'<em> </em>=> 'ValueTwenty', );
All array values must be followed by a comma, including the final value.

Valid: Comma after each value.

$array = array( 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'<em>,</em> );

Invalid: No comma after last value.

$array = array( 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'<em> </em> );