开发者

Zend currency custom format like "$ 1,234.56 USD"

I'm using the zend currency module to manage currencies in a web app. I can't figure out how to create a custom format for my currencies, since there are no examples on the documentation pages: http://framework.zend.com/manual/en/zend.currency.options.html

From what I read there, I could use the format parameter to set a format, but I can't find a way how. Does anyone have a good code example for this problem?

currently I do the following:

$currenc开发者_运维技巧y->setFormat(array (display' => Zend_Currency::USE_SYMBOL));

That works to display only the symbol, but I'm also interested in putting an extra space after or before the symbol and to display currencies like this:

"$ 1,234.56 USD" "€ 1.234,56 EUR"


This is as far as I came in getting it to work. I'm not sure how to tell Zend_Currency to use my format instead of the default, but I'd imagine you have to mess with Zend_Locale and tell it to use your custom format.

$currency = new Zend_Currency(array(
    'value'  =>  1234.56,
    'currency'  =>  'USD'
));

$currency = Zend_Locale_Format::toNumber(1234.56, array(
    'number_format'  =>  '$ #,##0.00 USD'
));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜