Break/explode String in smarty

temp-learn picture temp-learn · Dec 2, 2011 · Viewed 24.4k times · Source

can some 1 tell how to break this sort of String in smarty what i want is "1" as price and "dollar" as currency type.

"1|dollar"

please reply.

Answer

Jan Hančič picture Jan Hančič · Dec 2, 2011

You could do something like this:

{assign var=someVar value="|"|explode:"1|dollar"}

and then access "1" and "dollar" through 0 and 1 indexes of the "someVar" variable like below,

{$somevar[0]} and {$somevar[1]}