* Added a percent() function
This commit is contained in:
parent
fc4eb0ad56
commit
be977a75d7
1 changed files with 10 additions and 0 deletions
|
|
@ -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%";
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue