| 625 | } |
| 626 | |
| 627 | private function floatvalue($val) { |
| 628 | // if value is a 3 digit comma number with one leading zero like 0,111, it should not go through the 1000 separator removal |
| 629 | if (preg_match('/(?<=\b0)\,(?=\d{3}\b)/', $val) === 0 && preg_match('/(?<=\b0)\.(?=\d{3}\b)/', $val) === 0) { |
| 630 | // remove , as 1000 separator |
| 631 | $val = preg_replace('/(?<=\d)\,(?=\d{3}\b)/', '', $val); |
| 632 | // remove . as 1000 separator |
| 633 | $val = preg_replace('/(?<=\d)\.(?=\d{3}\b)/', '', $val); |
| 634 | } |
| 635 | // convert remaining comma to decimal point |
| 636 | $val = str_replace(",", ".", $val); |
| 637 | if (is_numeric($val)) { |
| 638 | return number_format(floatval($val), 2, '.', ''); |
| 639 | } else { |
| 640 | return false; |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | } |