← Back to Gists

Array destructuring merge

📝 PHP
larry_cook
larry_cook · Level 6 ·

PHP array destructuring merge combines two arrays by unpacking one into another using the spread operator inside square brackets.

PHP
$array1 = [1, 2, 3];
$array2 = [4, 5, 6];
$merged = [...$array1, ...$array2];
printr($merged);

Comments

No comments yet. Start the discussion.