No comma after last element in array?

后端 未结 4 1868
悲&欢浪女
悲&欢浪女 2021-01-01 19:10

I noticed that some arrays don\'t have a comma after the last item. I have an array:

$first_name = array(
              \'name\'        => \'first_name\',         


        
4条回答
  •  温柔的废话
    2021-01-01 20:03

    Both are syntactically correct in a number of languages. The last element is ignored if left blank. It is a nice little easter egg built into languages just so you don't have to keep adding in , before you start modifying an array if you manually have to add a few more values in.

提交回复
热议问题