PHP 8 · Strings and arrays

Merge arrays

Combine arrays with the spread operator.

$all = [...$first, ...$second];

Official PHP 8 documentation

More strings and arrays commands

All strings and arrays commands · PHP 8 cheatsheet

Was this page helpful?