Submitted : |explode

**SPIP**

# Article submitted

The article "**|explode**
(https://www.spip.net/ecrire/?exec=article&id_article=6568)" is submitted
for publication. on Monday 25 May 2020.

* * *

## |explode

Monday 25 May 2020 , by [jack](.././?page=auteur&id_auteur=593&)

The filter **code>|explode</code>** 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{ma_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

**Warning:**
- 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
(https://www.spip.net/ecrire/?exec=article&id_article=5672)

— Sent by SPIP (https://www.spip.net/)

rubon199.jpg

puce.gif