From 201ffd3d7a9a7c93b45655e20e8e9bca097caccc Mon Sep 17 00:00:00 2001 From: Lukas Halbritter Date: Thu, 4 Oct 2018 20:32:46 +0200 Subject: [PATCH] Added a method to replace every ',' in a string with a '.'. --- app/Http/helpers.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Http/helpers.php b/app/Http/helpers.php index ec4f914..8587dbd 100644 --- a/app/Http/helpers.php +++ b/app/Http/helpers.php @@ -52,6 +52,17 @@ function formatAmount(float $amount, $cash = true, $text = false, return number_format(abs($amount), $decimals, ',', '.') . $euro; } +/** + * Replace all commas in a string by a dot. This can be useful to convert + * strings that represent a float and use a comma as decimal point to a string + * of the same float but with a dot as decimal point. + * + * @return string + */ +function swapComma(string $floatString) { + return str_replace(',', '.', $floatString); +} + /** * Return a formatted date string. *