Skip to main content

Poll

Which version do you prefer?

single line
multiple lines
Topic: Arrays (Read 6284 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Arrays

Code: (single line) [Select]
	$config_vars = array(
array('title', 'attachment_manager_settings'),
// Are attachments enabled?
array('select', 'attachmentEnable', array($txt['attachmentEnable_deactivate'], $txt['attachmentEnable_enable_all'], $txt['attachmentEnable_disable_new'])),
'',
// Extension checks etc.
array('check', 'attachmentRecodeLineEndings'),
'',
// Directory and size limits.
array('select', 'automanage_attachments', array(0 => $txt['attachments_normal'], 1 => $txt['attachments_auto_space'], 2 => $txt['attachments_auto_years'], 3 => $txt['attachments_auto_months'], 4 => $txt['attachments_auto_16'])),

Code: (multiple lines) [Select]
	$config_vars = array(
array(
'title',
'attachment_manager_settings'
),
// Are attachments enabled?
array(
'select',
'attachmentEnable',
array(
$txt['attachmentEnable_deactivate'],
$txt['attachmentEnable_enable_all'],
$txt['attachmentEnable_disable_new']
)
),
'',
// Extension checks etc.
array(
'check',
'attachmentRecodeLineEndings'
),
'',
// Directory and size limits.
array(
'select',
'automanage_attachments',
array(
0 => $txt['attachments_normal'],
1 => $txt['attachments_auto_space'],
2 => $txt['attachments_auto_years'],
3 => $txt['attachments_auto_months'],
4 => $txt['attachments_auto_16']
)
),
Bugs creator.
Features destroyer.
Template killer.

Re: Arrays

Reply #1

Woot ... I voted ... but I need a 3rd option of "it depends" :P ....  But for the config var things I like the single line

Re: Arrays

Reply #2

Some are becoming quite ugly... (attachments in particular with lots of ternaries, and conditions, etc.)
Bugs creator.
Features destroyer.
Template killer.

Re: Arrays

Reply #3

I agree with Spuds. It depends. Length, if I have key/val or just val, and do I plan on adding more later.

[php]array(0,1,2)[/php]
 doesn't look bad compared to
[php]
array(
     0,
     1,
     2,
);[/php]
A looks worse than b in this one: [php]array(0 => 'a', 1 => 'b', 2 => 'c');[/php]
[php]
array(
     0 => 'a',
     1 => 'b',
     2 => 'c',
);[/php]
Even worse is this one: [php]array('theBrownFox' => 'was', 'smaller' => 'than', 'theRed' => 'fox, but the brown fox made up for it with tenacity');[/php]

Re: Arrays

Reply #4

 TestMonkey looks at the result, and calls Feature Cat, bluish, a great username-thing, to vote for multiple lines.  O:-)
The best moment for testing your PR is right after you merge it. Can't miss with that one.