Skip to content

Instantly share code, notes, and snippets.

@matthewpoer
Created July 7, 2020 14:12
Show Gist options
  • Select an option

  • Save matthewpoer/9444d3fd41fe3663eb15e470e25f1e77 to your computer and use it in GitHub Desktop.

Select an option

Save matthewpoer/9444d3fd41fe3663eb15e470e25f1e77 to your computer and use it in GitHub Desktop.
Merging arrays with array_push()
<?php
$a = array(
'one',
'two',
'three',
);
$b = array(
'four',
'five',
'six',
);
array_push($a, ...$b);
var_dump($a);
/*
array(6) {
[0]=>
string(3) "one"
[1]=>
string(3) "two"
[2]=>
string(5) "three"
[3]=>
string(4) "four"
[4]=>
string(4) "five"
[5]=>
string(3) "six"
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment