user132546 user132546 - 1 year ago 879
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}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download