You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== array_merge ==
[[../objects/ms.lang.CastException|ms.lang.CastException]] |- ! scope="row" | Since | 3.3.0 |- ! scope="row" | Restricted |
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Merges the specified arrays from left to right, and returns a new array. If the array merged is associative, it will overwrite the keys from left to right, but if the arrays are normal, the keys are ignored, and values are simply pushed.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| array_merge
|-
! scope="row" | Returns
| array
|-
! scope="row" | Usages
| array1, array2, [arrayN...]
|-
! scope="row" | Throws
| [[../objects/ms.lang.InsufficientArgumentsException|ms.lang.InsufficientArgumentsException]][[../objects/ms.lang.CastException|ms.lang.CastException]] |- ! scope="row" | Since | 3.3.0 |- ! scope="row" | Restricted |
No
|-
! scope="row" | Optimizations
| [[../../Optimizer#NO_SIDE_EFFECTS|NO_SIDE_EFFECTS]]
|}
=== Usages ===
array_merge(array1, array2, [arrayN...])=== Examples === ====Example 1==== Basic usage Given the following code:
array_merge(array(1), array(2), array(3))

1 {{function|array_merge}}({{function|array}}(1), {{function|array}}(2), {{function|array}}(3))
:{1, 2, 3}====Example 2==== With associative arrays Given the following code:
array_merge(array(one: 1), array(two: 2), array(three: 3))

1 {{function|array_merge}}({{function|array}}(one: 1), {{function|array}}(two: 2), {{function|array}}(three: 3))
:{one: 1, three: 3, two: 2}====Example 3==== With overwrites Given the following code:
array_merge(array(one: 1), array(one: 2), array(one: 3))

1 {{function|array_merge}}({{function|array}}(one: 1), {{function|array}}(one: 2), {{function|array}}(one: 3))
:{one: 3}===See Also===
[[API/functions/array_intersect.html|array_intersect]]
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)