diff --git a/includes/utilities.php b/includes/utilities.php index 6f01d15e..daf48799 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -115,26 +115,21 @@ abstract class Util public static function formatMoney(int $qty) : string { - $money = ''; + if ($qty <= 0) + return ''; - if ($qty >= 10000) - { - $g = floor($qty / 10000); - $money .= ''.$g.' '; - $qty -= $g * 10000; - } + $parts = []; - if ($qty >= 100) - { - $s = floor($qty / 100); - $money .= ''.$s.' '; - $qty -= $s * 100; - } + if ($g = intdiv($qty, 10000)) + $parts[] = ''.$g.''; - if ($qty > 0) - $money .= ''.$qty.''; + if ($s = intdiv($qty % 10000, 100)) + $parts[] = ''.$s.''; - return $money; + if ($c = ($qty % 100)) + $parts[] = ''.$c.''; + + return implode(' ', $parts); } // pageTexts, questTexts and mails