Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -1276,4 +1276,14 @@ |
1277 | 1277 | } |
1278 | 1278 | } |
1279 | 1279 | |
| 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 | +} |
1280 | 1290 | ?> |