Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

[SOLVED] How to 'explode' in Volt?

Dear experts,

Is there any way to 'explode' in Volt? I want to create array from a string. For example:

{% set arr = explode(mystrings, ',') %}

I saw join but not the opposite.

Thanks a lot.


Hi Jim,

I think you need to prepare your data in a controller or a model and then pass already "exploded" string into volt template. Or you can extend Volt engine as described here:

edited Oct '14

Hello Eugene,

Thank you for your suggestion. I'll dig up deeper into it.

I ended with this solution:

<?php $ids = explode(',', $doc->ids) ?>
{% for id in ids %}
<p>Row-{{ id }}</p>
{% endfor %}