Stuart Wright
Well-known member
I needed to create a comma separated list of items from an array in a template.
But not have a comma after the last item.
I did it this way. Hope it helps.
To identify the last item, $i == count($array)
But not have a comma after the last item.
I did it this way. Hope it helps.
Code:
<xf:foreach loop="$array" value="$item" i="$i">
{$item}<xf:if is="{$i} < count($array)">,</xf:if>
</xf:foreach>
To identify the last item, $i == count($array)