Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

Aligning Arrays

Arrays should be formatted with a space separating each element after the comma (,) and spaces around the => key association operator if possible.
Note that if the line declaring an array spans longer than 80 characters, each element should be broken into its own line and indented one level

INCORRECT
// No spacing
Code
$my_array = array("apple"=>"red","banana"=>"yellow","watermelon"=>"green");


// Bad indentation and mixed breaks, inconsistent spacing.
Code
$my_array = array(
 "apple"=> "red", "banana"=>"yellow",
 "watermelon" =>"green",
"Lemon"=> "yellow",
"Strawberry" => "red");

CORRECT
// Spacing as required
Code
$my_array = array("apple" => "red", "banana" => "yellow", "watermelon" => "green");


// Good indentation, nice breaks, consistent spacing, ends with a ,
Code
$my_array = array(
   "apple"      => "red",
   "banana"     => "yellow",
   "watermelon" => "green",
   "Lemon"      => "yellow",
   "Strawberry" => "red"
);


The comma at the end of the last array allows the parenthesis to have it´s own line,
it also allows help to prevent parsing errors if another element is placed at the end of the list later.