user132546 user132546 - 1 year ago 545
Smarty Question

smarty convert string to Integer/Float

I have some string value, like

$value = "123.45";

Since I have to compare this
with Integer, I need to convert
's type to float.

How can I convert String to Integer/Float in smarty language?


Answer Source

you can use php's functions floatval / intval in smarty:

{$value = $value|floatval}
{$value = $value|intval}

Multiplying by 1 would also work:

{$value = $value*1}