...
Arrays
Numerically Index Arrays
Each array element should be separated by a comma and a space character. If wrapping an array across multiple lines, subsequent lines should be indented.
Tip |
---|
|
Code Block |
---|
| $shapes = array("circle", "square", "triangle", "hexagon");
$colors = array(
"red", "pink",
"green", "purple"
); |
|
Associative Arrays
Associative arrays should have a space before and after the => assignment. Array indexes should be quoted using single quotes ('). Short arrays can contain all elements on a single line, but it's recommend to set each index on its own line.
Tip |
---|
|
Code Block |
---|
| $blocks = array(
'circle' => "red",
'square' => "pink",
'triangle' => "green",
'hexagon' => "purple"
); |
|
Multidimensional Arrays
Each array depth should be indented one level. The ending parenthesis of the array should be indented such that it aligns with the indent level of its defining index.
Tip |
---|
|
Code Block |
---|
| $polygons = array(
'triangles' => array(
"obtuse",
"acute",
"right"
),
'quadrilaterals' => array(
"square",
"rhombus",
"rectangle"
)
); |
|
Constants
Constants should always be capitalized.
...