twig_split_filter()
twig_split_filter(\Twig_Environment $env, string $value, string $delimiter, integer $limit = null) : array
Splits the string into an array.
{{ "one,two,three"|split(',') }}
{# returns [one, two, three] #}
{{ "one,two,three,four,five"|split(',', 3) }}
{# returns [one, two, "three,four,five"] #}
{{ "123"|split('') }}
{# returns [1, 2, 3] #}
{{ "aabbcc"|split('', 2) }}
{# returns [aa, bb, cc] #}
Parameters
\Twig_Environment |
$env |
|
string |
$value |
A string |
string |
$delimiter |
The delimiter |
integer |
$limit |
The limit |
Returns
array
— The split string as an array