0

I am outputting a value using toCurrency() from Zend:

echo $currency->toCurrency(1000, array('currency' => "GBP", 'precision' => 2));

Which gives me an example of £ 1,999.99, without using any extra code such as preg repplace can i return the value with NO symbol?

Complete code:

// $locale is set by browser
Zend_Registry::set('Zend_Locale', $locale);
$currency = new Zend_Currency();
echo $currency->toCurrency(1000, array('currency' => "GBP", 'precision' => 2));
// £1,000.00 but would like only 1,000.00

If anyone needs to know more information please do not hesitate to ask.

If anyone is curious as to what I am doing mashing two currencies together, I am displaying monetary values in a localised format but representing them in GBP. This is why I would prefer to avoid using a strip/replace method because I can not guarantee accuracy when representing values.

Ne Ma
  • 1,719
  • 13
  • 19

1 Answers1

1

You may specify the 'symbol' to display your currency with. This includes an empty string:

echo $currency->toCurrency(
    1000,
    array(
        'currency' => "GBP",
        'precision' => 2
        'symbol' => ''
    )
 );

Reference

Richard Parnaby-King
  • 14,703
  • 11
  • 69
  • 129
  • You sir are awesome. Have an up click. Just a short note, the currency symbol was still returned until currency was taken out of the array. This leads me to believe that currency takes precedence over symbol when both are present. – Ne Ma Dec 17 '12 at 12:40
  • I was unaware of that. Very interesting. I wonder if that is intentional or a bug of some sort? – Richard Parnaby-King Dec 17 '12 at 14:05