From: Ævar Arnfjörð Bjarmason Date: Sat, 16 Jul 2005 21:59:53 +0000 (+0000) Subject: * Added a percent() function X-Git-Tag: 1.5.0beta4~117 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_del%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=commitdiff_plain;h=be977a75d7b3fd55843d19cfffa79f4f13be5f47;p=lhc%2Fweb%2Fwiklou.git * Added a percent() function --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 07e7750c0d..c0c9e0abaf 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1276,4 +1276,14 @@ function wfIncrStats( $key ) { } } +/** + * @param mixed $nr The number to format + * @param int $acc The number of digits after the decimal point, default 2 + * @param bool $round Whether or not to round the value, default true + * @return float + */ +function percent( $nr, $acc = 2, $round = true ) { + $ret = sprintf( "%.${acc}f", $nr ); + return $round ? round( $ret, $acc ) . '%' : "$ret%"; +} ?>