由于我是smarty的新手,我无法将浮点数转换为int.例如:12.234 => 12请帮助我,如果你找到任何解决方案
ale*_*lex 15
为什么不在将它附加到视图之前进行投射.没有理由传递需要进一步处理的视图数据.
$int = (int) $float;
$smarty->assign(array(
'number' = $int
));
Run Code Online (Sandbox Code Playgroud)
如果你真的必须使用Smarty获取浮点数的整数部分,试试这个......
{$number|string_format:"%d"}
Run Code Online (Sandbox Code Playgroud)
就像PHP一样printf().