Kimai_Format::formatCurrency PHP Method

formatCurrency() public static method

Format a currency or an array of currencies accordingly.
public static formatCurrency ( integer | array $number, boolean $htmlNoWrap = true ) : integer | array | string
$number integer | array one value or an array of decimal numbers
$htmlNoWrap boolean
return integer | array | string formatted string(s)
    public static function formatCurrency($number, $htmlNoWrap = true)
    {
        global $kga;
        if (is_array($number)) {
            // Convert all values of the array.
            $arr = array();
            foreach ($number as $key => $value) {
                $arr[$key] = self::formatCurrency($value);
            }
            return $arr;
        }
        $value = str_replace(".", $kga['conf']['decimalSeparator'], sprintf("%01.2f", $number));
        if ($kga->isDisplayCurrencyFirst()) {
            $value = $kga->getCurrencySign() . " " . $value;
        } else {
            $value = $value . " " . $kga->getCurrencySign();
        }
        if ($htmlNoWrap) {
            return "<span style=\"white-space: nowrap;\">{$value}</span>";
        }
        return $value;
    }

Usage Example

コード例 #1
0
ファイル: base_export_pdf.php プロジェクト: kimai/kimai
 /**
  * Format a number as a money value.
  *
  * @param int $number amount of money
  * @return string formatted string
  */
 public function money($number)
 {
     return Kimai_Format::formatCurrency($number, false);
 }
All Usage Examples Of Kimai_Format::formatCurrency