Explode on template syntax


First of all, sorry if this topic doesn't belong here.

I'm having some troubles doing some custom content on my XF. I have a field ($var.field) which is a string ('3, 4, 5, 13') and i want to evaluate it on the foreach.

<xen:foreach loop="$vars" value="$var">

So i want to know if '3' is inside $var.field. As a single 3, not as a part of the string (so first 3 is valid, but 3 from 13 isn't).

I was thinking on (strpos({$var.field}, '3') ==! false) but that returns any 3 on the string.

As i can't explode the string using ',', how can i do that?


To solve my problem, i guess there's another way.
I'm fetching whole xf_thread (select xf_thread.*) and $vars is a row there. How can i parse my fetch (stored on $sql for example) to parse xf_thread.vars, which is a string, and save it as an array (exploding on ',') on $sql?

So on the template $var.field will be an array and i can simply evaluate what i need with a (in_array('3', {$var.field}))

Thanks for the help!


Sorry, already figured out second part (converting the string on an array).

What about the explode on the template?