1
在Zend2你可以這樣做:Zend2:指定貨幣前綴?
<?php echo $this->currencyFormat(120, 'ZAR'); ?>
這將導致:
ZAR 120.00
不過,我想直到結束:
R 120.00
如何設置前綴而不是代碼中的貨幣符號?以下不起作用(顯然):
<?php echo $this->currencyFormat(120, 'R'); ?>
在Zend2你可以這樣做:Zend2:指定貨幣前綴?
<?php echo $this->currencyFormat(120, 'ZAR'); ?>
這將導致:
ZAR 120.00
不過,我想直到結束:
R 120.00
如何設置前綴而不是代碼中的貨幣符號?以下不起作用(顯然):
<?php echo $this->currencyFormat(120, 'R'); ?>
自己想出來。易就象這樣:
$helper->setCurrencyPattern('R #0.#');
所以完整的代碼,讓我在一個地方(Module.php)控制一切如下:
class Module
{
public function getConfig()
{
return array(
'view_helpers' => array(
'factories' => array(
'currencyFormat' => function($sm)
{
$helper = new \Zend\I18n\View\Helper\CurrencyFormat;
$helper->setCurrencyCode("ZAR");
$helper->setLocale('us_ZA');
$helper->setCurrencyPattern('R #0.#');
return $helper;
},
)
),
);
}
}
享受...