How to merge array in volt

Hi all

Volt do have support merge array ?

    {% set menuItems = ['organization': 'Organizations', 'project': 'Projects', 'job': 'Jobs'
    ]%}
    {% set menuAdmin = ['user': 'Users', 'role': 'Roles',  'project': 'Projects','template' : 'Email Templates' ,'configuration' : 'Configurations'
    ]%}
    {% if this.session.get('auth')['role']['name'] == 'Superadmin'%}
          {% set menuItems =[ menuAdmin, menuItems ]%}
    {% endif %}

{% set menuItems =[ menuAdmin, menuItems ]%} is that working, but is two element


Array
(
    [0] => Array
        (
            [user] => Users
            [role] => Roles
            [task] => Tasks
            [tag] => Tags
            [project] => Projects
            [template] => Email Templates
            [configuration] => Configurations
        )

    [1] => Array
        (
            [organization] => Organizations
            [project] => Projects
            [job] => Jobs
        )

)

I want look like

    Array
(
    [user] => Users
    [role] => Roles
    [task] => Tasks
    [tag] => Tags
    [project] => Projects
    [template] => Email Templates
    [configuration] => Configurations
    [organization] => Organizations
    [project] => Projects
    [job] => Jobs
)

Thanks all



4.6k

You can create a volt extension which provides this functionality.

Check this: http://docs.phalconphp.com/en/latest/reference/volt.html#extending-volt

use the following;

{% set myArray = myArray | merge({ "key" : "value" }) %}