function twig_join_filter

Joins the values to a string.

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

<pre> {{ [1, 2, 3]|join('|') }} {# returns 1|2|3 #}

{{ [1, 2, 3]|join }} {# returns 123 #} </pre>

Parameters

array $value An array:

string $glue The separator:

Return value

string The concatenated string

1 string reference to 'twig_join_filter'
Twig_Extension_Core::getFilters in drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php
Returns a list of filters to add to the existing list.

File

drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php, line 617

Code

function twig_join_filter($value, $glue = '') {
  if ($value instanceof Traversable) {
    $value = iterator_to_array($value, false);
  }
  return implode($glue, (array) $value);
}