views:

260

answers:

1

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:

$currency->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"

+1  A: 

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'
));
Ballsacian1