How much is my currency? - Zend_Currency
How much is my currency?
When you are working with currencies then you normally want to display an amount of money. And when you work with different currencies then you have to do this with three different things. The amount you want to display, the precision you want to use, and probably the exchange rate.
Working with currency values
The currency value, a.k.a. the money, you want to use can easily be set by using the value option.
Using the setFormat() method with this array option, and also by using the setValue() method you can set the value afterwards.
With the getValue() method you will get the actual set value.
Using precision on currencies
When working with currencies they you probably also have to handle precision. Most currencies use a precision of 2. This means that when you have 100 US dollars you could also have 50 cents. The related value is simply a floating value.
Of course, as the default precision is 2, you will get '00' for the decimal value when there is no precision to display.
To get rid of this default precision you could simply use the precision option and set it to '0'. And you can set any other precision you want to use between 0 and 9. All values will be rounded or streched when they don't fit the set precision.