views:

100

answers:

1

I'm using zend currency to display the currency based on locale. When I use the following code the symbol gets replaced by 1 instead of simply being removed:

$currency = new Zend_Currency($locale); $currency->setFormat(array('symbol' => Zend_Currency::NO_SYMBOL));

What normally gets returned is this: € 2.500,01 but after the "setFormat" call I'm getting this: 1 2.500,01

I don't want the "1 " in there.

Any ideas on how to fix this?

Thanks.

+1  A: 

You're setting the wrong option in setFormat. You need to set display to Zend_Currency::NO_SYMBOL. Like this:

$c = new Zend_Currency();
$c->setFormat(array('display' => Zend_Currency::NO_SYMBOL));
echo $c->toCurrency(2500.01);

Which outputs

2,500.01

The way you are currently doing it is literally setting the symbol to 1 because that's what the constant NO_SYMBOL evaluates to.

Mark
That fixed it. Thank you!
Ronedog