Added helper function 'formatAmount' to auto format floats top german format.

This commit is contained in:
Lukas Halbritter
2018-09-13 15:55:42 +02:00
parent 562cbe6b9a
commit 1b10f45a7d
+15
View File
@@ -19,3 +19,18 @@ function rand_bool($prob = 50) {
return $rand <= $prob;
}
/*
* Return the formatted string representation of a floatng point number.
*
* The decimal point is a ',', the thousands seperator ist set to '.'.
* The number of decimals is 2 by default but can be set by the $decimals
* argument.
*
* @param integer $decimals Sets the number of decimal points.
*
* @return string
*/
function formatAmount(float $amount, $decimals = 2) {
return number_format($amount, $decimals, ',', '.');
}