public static function parseDouble($data)
{
$data = \preg_replace('/[^0-9\\.,\\-]/', "", $data);
$data = \str_replace(" ", "", \trim($data));
$double = 0;
if ($data != null) {
$bits = \explode(",", \trim($data));
// split input value up to allow checking
$last = \strlen($bits[\count($bits) - 1]);
// gets part after first comma (thousands (or decimals if incorrectly used by user)
if ($last < 3) {
// checks for comma being used as decimal place
$convertnum = \str_replace(",", ".", \trim($data));
} else {
$convertnum = \str_replace(",", "", \trim($data));
}
$double = \number_format((double) $convertnum, 2, '.', '');
}
return $double;
}