From 74f8ef5cebc3d1a92e40f757e95861cbc30565b9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 12 Apr 2005 23:21:59 +0000 Subject: [PATCH] * 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. --- languages/Language.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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; -- 2.20.1