| 768 | } |
| 769 | |
| 770 | private function floatvalue($val) { |
| 771 | // if value is a 3 digit comma number with one leading zero like 0,111, it should not go through the 1000 separator removal |
| 772 | if (preg_match('/(?<=\b0)\,(?=\d{3}\b)/', $val) === 0 && preg_match('/(?<=\b0)\.(?=\d{3}\b)/', $val) === 0) { |
| 773 | // remove , as 1000 separator |
| 774 | $val = preg_replace('/(?<=\d)\,(?=\d{3}\b)/', '', $val); |
| 775 | // remove . as 1000 separator |
| 776 | $val = preg_replace('/(?<=\d)\.(?=\d{3}\b)/', '', $val); |
| 777 | } |
| 778 | // convert remaining comma to decimal point |
| 779 | $val = str_replace(",", ".", $val); |
| 780 | if (is_numeric($val)) { |
| 781 | return number_format(floatval($val), 2, '.', ''); |
| 782 | } else { |
| 783 | return false; |
| 784 | } |
| 785 | } |
| 786 | |
| 787 | } |