# Trailing Commas in Function and Method calls

> Section in “New and Extended Functionality › Language Features” of the book [PHP 7 Explained](https://php7explained.com/) by Sebastian Bergmann and Stefan Priebsch, published by thePHP.cc. The book covers PHP 7.0 to 7.4 and was last updated in November 2020. HTML version: <https://php7explained.com/new-and-extended-functionality/language-features/trailing-commas-in-function-and-method-calls/>

When defining arrays in PHP, for quite some time, trailing commas were allowed. The following code example is legal PHP syntax:

``` php
$array = [1, 2,];
```

While trailing commas may look awkward at fist glance, it can make copying and pasting and reordering multiple arguments a lot easier:

``` php
$array = [
    [1, 2, 3],
    [7, 8, 9],
    [4, 5, 6],
];
```

Since PHP 7.3, trailing commas are also allowed in method calls:

``` php
foo(1, 2);
foo(1, 2,);

function foo($a, $b)
{
}
```

While this change may seem minor, it can actually simplify code generators quite a bit.

---

Previous: [Numeric Literal Separator](https://php7explained.com/new-and-extended-functionality/language-features/numeric-literal-separator/index.html.md) | Next: [Constants](https://php7explained.com/new-and-extended-functionality/constants/index.html.md)
