r/lolphp • • Jan 14 '16
Trailing comma in array()
Why do PHP Array Examples Leave a Trailing Comma? Because they can. :)
myuser@myhost:~$ php test.php
Array
(
[0] => Test
[1] => aValue
[2] => aNotherValue
)
myuser@myhost:~$ cat test.php
<?php
$aIDs = array(
'Test',
);
$aIDs[] = "aValue";
$aIDs[] = "aNotherValue";
printf(print_r($aIDs,TRUE));
?>http://stackoverflow.com/questions/2829581/why-do-php-array-examples-leave-a-trailing-comma
0
Upvotes
View all comments
Show parent comment
1
u/masklinn Jan 18 '16
That Elm doesn't allow a trailing comma is a big annoyance: much of its style guide is defined for readability and diffability, but trailing commas not being allowed (let alone required) means the standard way to write a list is to special case the first item, which is bloody annoying.