Split
2 min read
Jun 2, 2026
---
title: split
autoseo:
enabled: true
theme: learn2
child_type: default
admin:
children_display_order: collection
visible: true
---
split — Splits a string into an array, using the optional second parameter as the separator.
Basic Usage:For $chars populated with 'abc', the following will produce a html list with 3 elements (a, b and c).
{$chars|split}
Parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
| 1 | string | No | separator used to split the string on. Defaults to empty string, causing each character in the source string to be separate. |
Where the template is:
<ol>
{foreach $chars|split as $char}
<li>{$char|escape}</li>
{/foreach}
</ol>
Output:
a
b
c
For $ids populated with '1,2,3,4,5', the following will produce a html list with 5 elements (1, 2, 3, 4 and 5).
<ol>
{foreach $ids|split:',' as $id}
<li>{$id}</li>
{/foreach}
</ol>
Output:
1
2
3
4
5
Leave a Comment