We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to set associative array in volt?

I want to set associative array in volt

{% set tempKey = "Name" %}

{% set tempArray[tempKey] = "Mike" %}

how to do that?



33.8k

{% set array = ['key': value] %}


2.7k

Hi, But if the Key is another variable, it's not working


{% set array = ['key': value] %}


33.8k

Yeah, you're right, 'cause you can't put a variable like a key. key is a string value, not a variable.