public static function currency($number, array $options = array()) {
        $defaults = array(
            'thousands' => ',',
            'decimals' => '.',
            'places' => 2,
            'code' => 'USD #',
            'dollar' => '$#',
            'cents' => '#&cent;',
            'use' => 'dollar',
            'negative' => '(#)'
        );

        $options = $options + $defaults;
        $amount = number_format(static::precision(abs($number), $options['places']), $options['places'], $options['decimals'], $options['thousands']);

        // Cents
        if (($number < 1 && $number > -1) && $options['cents']) {
            $amount = str_replace('#', $amount, $options['cents']);

        // Dollars
        } else {
            if ($options['use'] === 'dollar') {
                $amount = str_replace('#', $amount, $options['dollar']);
            } else {
                $amount = str_replace('#', $amount, $options['code']);
            }
        }

        // Negative
        if ($number < 0 && $options['negative']) {
            $amount = str_replace('#', $amount, $options['negative']);
        }

        return $amount;
    }
public static function currency($number, array $options = array()) {
        $defaults = array(
            'thousands' => ',',
            'decimals' => '.',
            'places' => 2,
            'code' => 'USD #',
            'dollar' => '$#',
            'cents' => '#&cent;',
            'use' => 'dollar',
            'negative' => '(#)'
        );

        $options = $options + $defaults;
        $amount = number_format(static::precision(abs($number), $options['places']), $options['places'], $options['decimals'], $options['thousands']);

        // Cents
        if (($number < 1 && $number > -1) && $options['cents']) {
            $amount = str_replace('#', $amount, $options['cents']);

        // Dollars
        } else {
            if ($options['use'] === 'dollar') {
                $amount = str_replace('#', $amount, $options['dollar']);
            } else {
                $amount = str_replace('#', $amount, $options['code']);
            }
        }

        // Negative
        if ($number < 0 && $options['negative']) {
            $amount = str_replace('#', $amount, $options['negative']);
        }

        return $amount;
    }
public static function currency ( $ number , array $ options = array ( ) ) { $ defaults = array ( 'thousands' => ',' , 'decimals' => '.' , 'places' => 2 , 'code' => 'USD #' , 'dollar' => '$#' , 'cents' => '#&cent;' , 'use' => 'dollar' , 'negative' => '(#)' ) ; $ options = $ options + $ defaults ; $ amount = number_format ( static :: precision ( abs ( $ number ) , $ options [ 'places' ] ) , $ options [ 'places' ] , $ options [ 'decimals' ] , $ options [ 'thousands' ] ) ; // Cents if ( ( $ number < 1 && $ number > - 1 ) && $ options [ 'cents' ] ) { $ amount = str_replace ( '#' , $ amount , $ options [ 'cents' ] ) ; // Dollars } else { if ( $ options [ 'use' ] === 'dollar' ) { $ amount = str_replace ( '#' , $ amount , $ options [ 'dollar' ] ) ; } else { $ amount = str_replace ( '#' , $ amount , $ options [ 'code' ] ) ; } } // Negative if ( $ number < 0 && $ options [ 'negative' ] ) { $ amount = str_replace ( '#' , $ amount , $ options [ 'negative' ] ) ; } return $ amount ; }
Convert a number to it's currency equivalent, respecting locale.
Allow for overrides through an options array.

@param int $number
@param array $options {
@type string $thousands Character used for thousands place
@type string $decimals  Character used for decimal
@type int $places       Decimal (cent) limit
@type string $code      Currency code with replaceable hash
@type string $dollar    Dollar sign with replaceable hash
@type string $cents     Cent sign with replaceable hash
@type string $use       Whether to use dollar or code for formatting
@type string $negative  Negative sign with replaceable hash
}
@return string
Convert a number to it s currency equivalent respecting locale . Allow for overrides through an options array .