Skip to content

vacreate / sacreate#


Description#

Create an array from a comma separate list of elements

Snippet#

<mvt:comment>
Create an array from a comma separate list of elements
</mvt:comment>

<mvt:assign name="g.list" value="'apples,oranges,bananas,grapes'" />

<mvt:assign name="l.count" value="1" />
<mvt:assign name="l.token" value="gettoken(g.list, ',' , l.count)" />

<mvt:while expr="NOT ISNULL l.token">
<mvt:assign name="l.array_length" value="miva_array_insert( l.settings:my_array, l.token, -1 )" />

    <mvt:assign name="l.count" value="l.count + 1" />
    <mvt:assign name="l.token" value="gettoken(g.list, ',' , l.count)" />

</mvt:while>

<mvt:foreach iterator="array_element" array="my_array">
&mvt:array_element;<br>
</mvt:foreach>

Functions Used#

  • gettoken