Introduction

The split filter is used to divide a string into smaller parts based on a specific delimiter. It returns an array containing the parts of the original string, which is useful for manipulating and accessing string subsections.

Example of use

Example of how to use the split filter to split a string into words:

{% set text = 'Hello World' %}
{% set words = text|split(' ') %}
{{ words[0] }} {# Returns "Hello" #}
{{ words[1] }} {# Returns "World" #}

Example Output Code