Pushing additional key values without overwriting existing key values in an array For an existing key in an associative array, I'm trying to push a new value to it without overwriting the existing values in the key. I've tried this:

{% set myArray = {
    myKey: [
        'value1',
    ]
} %}
{% set myArray = myArray|merge({key: 'value2'}) %} 


But this returns [ 'myKey' : 'value2']. I'm trying to get it to return [ 'myKey' : [ 0 =&gt; 'value1', 1 =&gt; 'value2'].
This should do it for you:

{% set myArray = {
    myKey: [
        'value1',
    ]
} %}

{% set myArray = myArray|merge({myKey: myArray.myKey | merge(['value2']) }) %}