| 659 | } |
| 660 | |
| 661 | private function floatvalue($val) { |
| 662 | // if value is a 3 digit comma number with one leading zero like 0,111, it should not go through the 1000 separator removal |
| 663 | if (preg_match('/(?<=\b0)\,(?=\d{3}\b)/', $val) === 0 && preg_match('/(?<=\b0)\.(?=\d{3}\b)/', $val) === 0) { |
| 664 | // remove , as 1000 separator |
| 665 | $val = preg_replace('/(?<=\d)\,(?=\d{3}\b)/', '', $val); |
| 666 | // remove . as 1000 separator |
| 667 | $val = preg_replace('/(?<=\d)\.(?=\d{3}\b)/', '', $val); |
| 668 | } |
| 669 | // convert remaining comma to decimal point |
| 670 | $val = str_replace(",", ".", $val); |
| 671 | if (is_numeric($val)) { |
| 672 | return number_format(floatval($val), 2, '.', ''); |
| 673 | } else { |
| 674 | return false; |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | } |