Created
July 7, 2020 14:12
-
-
Save matthewpoer/9444d3fd41fe3663eb15e470e25f1e77 to your computer and use it in GitHub Desktop.
Merging arrays with array_push()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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