The filter |explode allows to cut a string according to a specified separator and to place each element in an array (array in the PHP sense).

For example, from #SET{my_date, '31/12/1999'},
#SET{my_array, #GET{my_date}|explode{/}} will generate the array having for elements "31", "12" and "1999"; [(#GET{my_array}|foreach)] will thus return:

0 => 31
1 => 12
2 => 1999

-  if the separator is the comma character, you have to enclose it in single quotes: #SET{my_array, #GET{my_variable}|explode{','}}
-  To make the filter more convenient to use in templates, |explode reverses the writing of the PHP function of the same name.

See also the filter |implode

Author jack Published :

Translations : English, français