Answers.Body: <p>You would use the <a href="http://twig.sensiolabs.org/doc/filters/split.html" rel="nofollow"><code>split</code></a> filter.</p>
  
  <pre><code>{% set fruits = "Apples; Bananas; Tomatoes" | split('; ') %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-14T18:31:57.017Z
Answers.Text: Strange why it is shown that my question was viewed only 1 Time...
Answers.UserDisplayName: nicael
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-14T18:36:54.323Z
Answers.Text: Of course fruits is MUCH more better and accurately then items. I had some doubts but now in 5 mins I'll accept your answer.
Answers.UserDisplayName: nicael
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-14T18:29:22.613Z
Answers.LastActivityDate: 2014-06-14T18:35:02.703Z
Answers.LastEditDate: 2014-06-14T18:35:02.703Z
Answers.UserDisplayName: Bill Criswell
Answers.Body: <p>Use <a href="http://twig.sensiolabs.org/doc/filters/split.html" rel="nofollow">Twig's split filter.</a></p>
  
  <pre><code>{{ "Apples; Bananas; Tomatoes"|split('; ') }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-14T18:30:47.553Z
Answers.LastActivityDate: 2014-06-14T18:30:47.553Z
Answers.UserDisplayName: Simon Kuran
Body: <p>How can I split (or explode) a Twig string like this:</p>
  
  <pre><code>{% set fruits = "Apples; Bananas; Tomatoes" %}
  </code></pre>
  
  <p>into an array like this:</p>
  
  <pre><code>{{ ["Apples", "Bananas", "Tomatoes"] }}
  </code></pre>
  
Tags: <templating><filter>
Title: How to split a string into an array
ThreadText: # How to split a string into an array
  
  (Asked by: username_0 on 2014-06-14)
  
  How can I split (or explode) a Twig string like this:
  
  ```
  {% set fruits = "Apples; Bananas; Tomatoes" %}
  
  ```
  
  into an array like this:
  
  ```
  {{ ["Apples", "Bananas", "Tomatoes"] }}
  
  ```
  
  **Tags:** templating, filter
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-06-14. Score: 5 | Accepted answer
  
  You would use the [`split`](http://twig.sensiolabs.org/doc/filters/split.html) filter.
  
  ```
  {% set fruits = "Apples; Bananas; Tomatoes" | split('; ') %}
  
  ```
  
  > **Comments:**
  > **username_0**: Strange why it is shown that my question was viewed only 1 Time...  
  > **username_0**: Of course fruits is MUCH more better and accurately then items. I had some doubts but now in 5 mins I'll accept your answer.  
  
  ---
  
  ### Answer by username_2 on 2014-06-14. Score: 1
  
  Use [Twig's split filter.](http://twig.sensiolabs.org/doc/filters/split.html)
  
  ```
  {{ "Apples; Bananas; Tomatoes"|split('; ') }}
  
  ```
  
  
  ---
  
  