简体   繁体   中英

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

Using float variables for money values is not good, see for example http://floating-point-gui.de/basic/

So if you are using integer values instead you could do something like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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