r10163 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r10162‎ | r10163 | r10164 >
Date:21:59, 16 July 2005
Author:avar
Status:old
Tags:
Comment:
* Added a percent() function
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1276,4 +1276,14 @@
12771277 }
12781278 }
12791279
 1280+/**
 1281+ * @param mixed $nr The number to format
 1282+ * @param int $acc The number of digits after the decimal point, default 2
 1283+ * @param bool $round Whether or not to round the value, default true
 1284+ * @return float
 1285+ */
 1286+function percent( $nr, $acc = 2, $round = true ) {
 1287+ $ret = sprintf( "%.${acc}f", $nr );
 1288+ return $round ? round( $ret, $acc ) . '%' : "$ret%";
 1289+}
12801290 ?>

Status & tagging log