user132546 user132546 - 2 months ago 102x
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?



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}