1
<documentation title="Array Declarations">
4
This standard covers all array declarations, regardless of the number and type of values contained within the array.
9
The <em>array</em> keyword must be lowercase.
13
<code title="Valid: array keyword lowercase">
15
$array = <em>a</em>rray('val1', 'val2');
18
<code title="Invalid: first letter capitialised">
20
$array = <em>A</em>rray('val1', 'val2');
26
The first array key must begin on the line after the <em>array</em> keyword.
30
<code title="Valid: first key on second line">
33
<em>'key1'</em> => 'value1',
38
<code title="Invalid: first key on same line">
40
$array = array(<em>'key1'</em> => 'value1',
48
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.
52
<code title="Valid: aligned correctly">
55
<em> </em>'key1' => 'value1',
56
<em> </em>'key2' => 'value2',
60
<code title="Invalid: keys and parenthesis aligned incorrectly">
63
<em>'</em>key1' => 'value1',
64
<em>'</em>key2' => 'value2',
71
All double arrow symbols must be aligned to one space after the longest array key. Alignment must be achieved using spaces.
75
<code title="Valid: keys and values aligned">
78
'keyTen'<em> </em>=> 'ValueTen',
79
'keyTwenty'<em> </em>=> 'ValueTwenty',
83
<code title="Invalid: alignment incorrect">
86
'keyTen'<em> </em>=> 'ValueTen',
87
'keyTwenty'<em> </em>=> 'ValueTwenty',
94
All array values must be followed by a comma, including the final value.
98
<code title="Valid: comma after each value">
103
'key3' => 'value3'<em>,</em>
107
<code title="Invalid: no comma after last value">
112
'key3' => 'value3'<em> </em>