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 join string Volt

Hi all

I have a problem

{% for tag in object.tag%}
    {% set value = tag.name %}
{% endfor %}

I want to variable value is name1, name2, name3...

Volt have support it

Would something like this work?

{% set value = tag.name1 ~ " " ~ tag.name2 %}

Do you want concatenate tag.name values?

To concatenate two string you can use:

{% set value = "this is " ~ "concatenated string." %}

To join tags with commas you can use join:

{% set tags = object.tag|join(', ') %}


58.4k

The first that is ok

The second error

Warning: join(): Invalid arguments passed in /home


5.2k
Accepted
answer

Hmm, maybe object.tag is not array?

I tested this code and works:

{% set tags = ['a','b','c', 'd'] %}
{{ tags|join(', ') }}

The output is a, b, c, d



58.4k

that right