在Zend2中你可以这样做:
<?php echo $this->currencyFormat(120, 'ZAR'); ?>
这将导致:
ZAR 120.00
但是,我想最终得到:
R 120.00
如何将前缀设置为货币符号,与代码相对应?以下不起作用(显然):
<?php echo $this->currencyFormat(120, 'R'); ?>
答案 0 :(得分:1)
自己想出来。这很容易:
$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;
},
)
),
);
}
}
...享受