2 && $value{$decimalPosition} == '.') { $decimal = '.'; } if ($len > 2 && $value{$decimalPosition} == ',') { $decimal = ','; } // if decimal is dot, replace all comma's and spaces with nothing. then parse as float (round to 4 pos) if ($decimal === '.') { $search = [',', ' ']; $value = str_replace($search, '', $value); } if ($decimal === ',') { $search = ['.', ' ']; $value = str_replace($search, '', $value); $value = str_replace(',', '.', $value); } if (is_null($decimal)) { // replace all: $search = ['.', ' ', ',']; $value = str_replace($search, '', $value); } $this->setCertainty(90); return round(floatval($value), 4); } }