简体   繁体   English

聪明地在“,”后面加上两个0

[英]Smarty add two 0 after ",'

I have my variable 我有我的变量

{assign var='reduc' value=$valueprice}
{assign var='prix' value='30,00'}

I did that 我做到了

{$prix - ($prix * $reduc)}

But i want the result to be displayed with two number after the "," at the end always ! 但我希望结果始终以“,”后的两个数字显示! like if the result is : 就像结果是:

30 => 30,00 
24,5 => 24,50

I already tried with |string_format:"%.2f" it is not working 我已经尝试过| string_format:“%。2f”,但是它不起作用

Using float variables for money values is not good, see for example http://floating-point-gui.de/basic/ 对货币值使用float变量不好,请参见例如http://floating-point-gui.de/basic/

So if you are using integer values instead you could do something like: 因此,如果您使用整数值,则可以执行以下操作:

{$dollar},{$cent|string_format:"%02d"}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM