From: Ævar Arnfjörð Bjarmason Date: Tue, 12 Apr 2005 23:21:59 +0000 (+0000) Subject: * Adding a new function to format numbers (commafy) and using it for formatNum X-Git-Tag: 1.5.0alpha1~287 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=74f8ef5cebc3d1a92e40f757e95861cbc30565b9;p=lhc%2Fweb%2Fwiklou.git * Adding a new function to format numbers (commafy) and using it for formatNum by default, this means that everyone that doesn't have a formatNum function will see the en_* format but those that do will continue to see what they already do. --- diff --git a/languages/Language.php b/languages/Language.php index 341e479cce..0ca074b91b 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -2390,9 +2390,19 @@ class Language { * a floating point number. */ function formatNum( $number ) { - return $number; + return $this->commafy($number); } - + + /** + * Adds commas to a given number + * + * @param mixed $_ + * @return string + */ + function commafy($_) { + return strrev((string)preg_replace('/(\d{3})(?=\d)(?!\d*\.)/','$1,',strrev($_))); + } + function listToText( $l ) { $s = ''; $m = count($l) - 1;