0
我需要fatfree框架格式化货币,但我不明白如何避免小数如何格式化货币fatfree框架
与
{0 ,number, currency}
我接受(当然)€11.000,00
但
{0 ,number, currency,int}
我EUR 11.000,00
任何提示?
我需要fatfree框架格式化货币,但我不明白如何避免小数如何格式化货币fatfree框架
与
{0 ,number, currency}
我接受(当然)€11.000,00
但
{0 ,number, currency,int}
我EUR 11.000,00
任何提示?
currency
过滤器不允许定义小数位数。
然而,您可以create your own filter完全符合您的需求。
下面是一个例子:
$tpl=Template::instance();
// declare a new filter named 'price'
$tpl->filter('price',function($price,$decimals=0){
return money_format('%.'.$decimals.'n',$price);
});
// test it:
echo $tpl->resolve('{{ 12 | price }}'); // € 12
echo $tpl->resolve('{{ 12.56 | price }}'); // € 13
echo $tpl->resolve('{{ 12.56, 2 | price }}'); // € 12,56
完美!多谢!!! – andymo