Documentation

Where is the currency? - Zend_Currency

Where is the currency?

The position where the currency sign or name will be displayed depends on the locale. Still, when you want to define this setting yourself you have to use the display option and provide one of the following constants:

Available positions for the currency
Constant Description
STANDARD Sets the standard position as defined within the locale
RIGHT Displays the currency representation at the right side of the value
LEFT Displays the currency representation at the left side of the value

Example #1 Setting the currency position

Let's assume that your client has again set "en_US" as locale. Using no option the returned value could look like this:

  1. $currency = new Zend_Currency(
  2.     array(
  3.         'value' => 100,
  4.     )
  5. );
  6.  
  7. print $currency; // Could return '$ 100'

So by using the default setting the currency (in our case $) could either be rendered left or right from the value. Now let's define a fixed position:

  1. $currency = new Zend_Currency(
  2.     array(
  3.         'value'    => 100,
  4.         'position' => Zend_Currency::RIGHT,
  5.     )
  6. );
  7.  
  8. print $currency; // Could return '100 $';

Note that in the second snippet the position of USD is fixed regardless of the used locale or currency.

Copyright

© 2006-2021 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts