Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coding Implode In TWIG

Tags:

twig

implode

coding twig to implode under this how?

for example, the contents of the variable $data1 = "input your name" and the variable $data2 = "input your address"

how to become a variable $result = "input your name, input your address" how coding to implode in twig?

like image 351
user1798945 Avatar asked Nov 07 '12 09:11

user1798945


People also ask

What is Twig syntax?

Twig is a template engine for the PHP programming language. Its syntax originates from Jinja and Django templates. It's an open source product licensed under a BSD License and maintained by Fabien Potencier. The initial version was created by Armin Ronacher.


1 Answers

I'm guessing you're looking for the join filter. It works exactly like implode does in php. Quoting from the manual page:

The join filter returns a string which is the concatenation of the items of a sequence:

{{ [1, 2, 3]|join }}
{# returns 123 #}

The separator between elements is an empty string per default, but you can define it with the optional first parameter:

{{ [1, 2, 3]|join('|') }}
{# returns 1|2|3 #}
like image 184
Maerlyn Avatar answered Sep 21 '22 04:09

Maerlyn