Hi, Sometimes I see arrays like the following:
array('item1' => array(
'subitem1',
'subitem2',
)
Why a comma is added at end of array wheras there is not any element after submitem2?
Hi, Sometimes I see arrays like the following:
array('item1' => array(
'subitem1',
'subitem2',
)
Why a comma is added at end of array wheras there is not any element after submitem2?
It makes it easier to append another entry at a later point in time.
The comma is not needed at all. But you will still find some interpreters/compilers still allowing to use it. You can think of it this way: the interpreters is allowing you to make little mistakes and wisely fixing it internally. This is just a user-friendly way. Nothing else at all.
And you should not use that extra comma because a lot of strict ones will not let you pass through! Like Internet Explorer while interpreting Javascript. But Firefox will allow it.