smarty convert string to number

php, smarty, smarty2

Solution

If it's already assigned to a variable, say $var, you can set the type of a variable like this:

{$converted = settype ($var, 'integer')}

You don't have to use the $converted value, but if you don't assign it, the bool will show up in your page.

or you could try

{$variable|intval}

Problem

I need to do deviding: ``` {math equation="x/y" x=$x y=$y} // $x = '2', $y = '3' ``` How to convert strings to numbers exactly in Smarty, coz I don't have access to proprietary code of CMS? Thanx! UPD: Smarty version: 2.6.18

Original source