# How does the currency look like?

How the value of a currency will be rendered depends mainly on the used locale. There are several informations which are set by the locale. Each of them can manually be overridden by using the proper option.

For example, most locales are using the Latin script for rendering numbers. But there are languages like "Arabic" which are using other digits. And when you have an Arabic website you may also want to render other currencies by using the Arabic script. See the following example:

Using a custom script

Let's expect that we are again using our "Dollar" currency. But now we want to render our currency by using the Arabic script.

    $currency = new Zend_Currency(
        array(
            'value'  => 1000,
            'script' => 'Arab',
        )
    );

    print $currency; // Could return '$ ١٬٠٠٠٫٠٠'

For more informations about available scripts look into Zend_Locale's chapter about numbering systems.

But also the formatting of a currency number (money value) can be changed. Per default it depends on the used locale. It includes the separator which will be used between thousands, which sign will be used as decimal point, and also the used precision.

    $currency = new Zend_Currency(
        array(
            'value'    => 1000,
            'currency' => 'USD'
            'format'   => 'de',
        )
    );

    print $currency; // Could return '$ 1.000'

There are two ways to define the format which will be used. You can either give a locale or define a format manually.

When you are using a locale for defining the format all is done automatically. The locale 'de', for example, defines '.' as separator for thousands and ',' as decimal point. Within English this is reversed.

    $currency_1 = new Zend_Currency(
        array(
            'value'    => 1000,
            'currency' => 'USD'
            'format'   => 'de',
        )
    );

    $currency_2 = new Zend_Currency(
        array(
            'value'    => 1000,
            'currency' => 'USD'
            'format'   => 'en',
        )
    );

    print $currency_1; // Could return '$ 1.000'
    print $currency_2; // Could return '$ 1,000'

When you define it manually then you must conform the format as described in this chapter about localizing. See the following:

    $currency = new Zend_Currency(
        array(
            'value'    => 1000,
            'currency' => 'USD'
            'format'   => '#0',
        )
    );

    print $currency; // Could return '$ 1000'

In the above snippet we deleted the separator and also the precision.