function twig_array_merge

Merges an array with another one.

<pre> {% set items = { 'apple': 'fruit', 'orange': 'fruit' } %}

{% set items = items|merge({ 'peugeot': 'car' }) %}

{# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car' } #} </pre>

Parameters

array $arr1 An array:

array $arr2 An array:

Return value

array The merged array

1 string reference to 'twig_array_merge'
Twig_Extension_Core::getFilters in drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php
Returns a list of filters to add to the existing list.

File

drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php, line 601

Code

function twig_array_merge($arr1, $arr2) {
  if (!is_array($arr1) || !is_array($arr2)) {
    throw new Twig_Error_Runtime('The merge filter only works with arrays or hashes.');
  }
  return array_merge($arr1, $arr2);
}