Search code examples
phpsmarty

Break/explode String in smarty


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.


Solution

  • 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]}